<html>
<head>
<title>File Source for functions.php</title>
<link rel="stylesheet" type="text/css" href="../media/style.css">
</head>
<body>

<table border="0" cellspacing="0" cellpadding="0" height="48" width="100%">
  <tr>
    <td class="header_top">smt2</td>
  </tr>
  <tr><td class="header_line"><img src="../media/empty.png" width="1" height="1" border="0" alt=""  /></td></tr>
  <tr>
    <td class="header_menu">
        
                                    
                                                                      		  [ <a href="../classtrees_smt2.html" class="menu">class tree: smt2</a> ]
		  [ <a href="../elementindex_smt2.html" class="menu">index: smt2</a> ]
		  	    [ <a href="../elementindex.html" class="menu">all elements</a> ]
    </td>
  </tr>
  <tr><td class="header_line"><img src="../media/empty.png" width="1" height="1" border="0" alt=""  /></td></tr>
</table>

<table width="100%" border="0" cellpadding="0" cellspacing="0">
  <tr valign="top">
    <td width="200" class="menu">
      <b>Packages:</b><br />
              <a href="../li_smt2.html">smt2</a><br />
              <a href="../li_PegasusPHP.html">PegasusPHP</a><br />
              <a href="../li_PHPMailer.html">PHPMailer</a><br />
            <br /><br />
                  
      
                </td>
    <td>
      <table cellpadding="10" cellspacing="0" width="100%" border="0"><tr><td valign="top">

<h1 align="center">Source for file functions.php</h1>
<p>Documentation is available at <a href="../smt2/_functions.php.html">functions.php</a></p>
<div class="src-code">
<ol><li><div class="src-line"><a name="a1"></a><span class="src-php">&lt;?php</span></div></li>
<li><div class="src-line"><a name="a2"></a><span class="src-doc">/**</span></div></li>
<li><div class="src-line"><a name="a3"></a><span class="src-doc">&nbsp;*&nbsp;smt2&nbsp;CMS&nbsp;core&nbsp;functions.</span></div></li>
<li><div class="src-line"><a name="a4"></a><span class="src-doc">&nbsp;*&nbsp;</span><span class="src-doc-tag">@date</span><span class="src-doc">&nbsp;27/March/2009</span></div></li>
<li><div class="src-line"><a name="a5"></a><span class="src-doc">&nbsp;*&nbsp;</span><span class="src-doc-tag">@rev</span><span class="src-doc">&nbsp;20/December/2009</span></div></li>
<li><div class="src-line"><a name="a6"></a><span class="src-doc">&nbsp;*/</span></div></li>
<li><div class="src-line"><a name="a7"></a><a href="http://www.php.net/error_reporting">error_reporting</a><span class="src-sym">(</span><span class="src-id">E_ALL&nbsp;</span>|&nbsp;<span class="src-id">E_STRICT</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a8"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a9"></a><a href="../smt2/_functions.php.html#functionunregister_GLOBALS">unregister_GLOBALS</a><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a10"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a11"></a><span class="src-comm">//&nbsp;ignore&nbsp;PHP&nbsp;strict&nbsp;notice&nbsp;if&nbsp;time&nbsp;zone&nbsp;has&nbsp;not&nbsp;been&nbsp;set&nbsp;in&nbsp;php.ini</span></div></li>
<li><div class="src-line"><a name="a12"></a><span class="src-var">$defaultTimeZone&nbsp;</span>=&nbsp;<span class="src-sym">@</span><a href="http://www.php.net/date_default_timezone_get">date_default_timezone_get</a><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a13"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a14"></a><span class="src-key">if&nbsp;</span><span class="src-sym">(</span><span class="src-var">$defaultTimeZone</span><span class="src-sym">)&nbsp;</span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a15"></a>&nbsp;&nbsp;<span class="src-var">$location&nbsp;</span>=&nbsp;<span class="src-var">$defaultTimeZone</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a16"></a><span class="src-sym">}&nbsp;</span><span class="src-key">else&nbsp;</span><span class="src-key">if&nbsp;</span><span class="src-sym">(</span><a href="http://www.php.net/ini_get">ini_get</a><span class="src-sym">(</span><span class="src-str">'date.timezone'</span><span class="src-sym">))&nbsp;</span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a17"></a>&nbsp;&nbsp;<span class="src-var">$location&nbsp;</span>=&nbsp;<a href="http://www.php.net/ini_get">ini_get</a><span class="src-sym">(</span><span class="src-str">'date.timezone'</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a18"></a><span class="src-sym">}&nbsp;</span><span class="src-key">else&nbsp;</span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a19"></a>&nbsp;&nbsp;<span class="src-var">$location&nbsp;</span>=&nbsp;<span class="src-str">'UTC'</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a20"></a><span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a21"></a><span class="src-comm">//&nbsp;set&nbsp;date</span></div></li>
<li><div class="src-line"><a name="a22"></a><a href="http://www.php.net/date_default_timezone_set">date_default_timezone_set</a><span class="src-sym">(</span><span class="src-var">$location</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a23"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a24"></a><span class="src-comm">//&nbsp;load&nbsp;base&nbsp;files</span></div></li>
<li><div class="src-line"><a name="a25"></a><a href="http://www.php.net/define">define</a><span class="src-sym">(</span><span class="src-str">'REQUIRED'</span><span class="src-sym">,&nbsp;</span><span class="src-id">dirname</span><span class="src-sym">(</span>__FILE__<span class="src-sym">))</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a26"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a27"></a><span class="src-comm">//&nbsp;----------------------------------------------------------&nbsp;smt2&nbsp;constants&nbsp;---</span></div></li>
<li><div class="src-line"><a name="a28"></a>require&nbsp;<span class="src-id">REQUIRED</span>.<span class="src-str">'/define.php'</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a29"></a>require&nbsp;<span class="src-id">REQUIRED</span>.<span class="src-str">'/messages.php'</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a30"></a><span class="src-comm">//&nbsp;---------------------------------------------------------------&nbsp;utilities&nbsp;---</span></div></li>
<li><div class="src-line"><a name="a31"></a>require&nbsp;<span class="src-id">REQUIRED</span>.<span class="src-str">'/class.domutil.php'</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a32"></a>require&nbsp;<span class="src-id">REQUIRED</span>.<span class="src-str">'/class.browser.php'</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a33"></a>require&nbsp;<span class="src-id">REQUIRED</span>.<span class="src-str">'/class.point.php'</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a34"></a><span class="src-comm">//&nbsp;------------------------------------------------------------&nbsp;database&nbsp;API&nbsp;---</span></div></li>
<li><div class="src-line"><a name="a35"></a>require&nbsp;<span class="src-id">REQUIRED</span>.<span class="src-str">'/functions.db.php'</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a36"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a37"></a><span class="src-doc">/**&nbsp;</span></div></li>
<li><div class="src-line"><a name="a38"></a><span class="src-doc">&nbsp;*&nbsp;Additional&nbsp;head&nbsp;tags.&nbsp;Enable&nbsp;inserting&nbsp;custom&nbsp;tags&nbsp;on&nbsp;page&nbsp;head.</span></div></li>
<li><div class="src-line"><a name="a39"></a><span class="src-doc">&nbsp;*&nbsp;</span><span class="src-doc-coretag">@global&nbsp;</span><span class="src-doc-type">array&nbsp;</span><span class="src-doc-var">$_headAdded&nbsp;</span></div></li>
<li><div class="src-line"><a name="a40"></a><span class="src-doc">&nbsp;*/</span></div></li>
<li><div class="src-line"><a name="a41"></a><span class="src-var">$_headAdded&nbsp;</span>=&nbsp;<span class="src-key">array</span><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a42"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a43"></a><span class="src-doc">/**&nbsp;</span></div></li>
<li><div class="src-line"><a name="a44"></a><span class="src-doc">&nbsp;*&nbsp;Checks&nbsp;if&nbsp;server&nbsp;is&nbsp;ready&nbsp;to&nbsp;work&nbsp;with&nbsp;smt2&nbsp;by&nbsp;comparing&nbsp;the&nbsp;server's&nbsp;$type&nbsp;version.</span></div></li>
<li><div class="src-line"><a name="a45"></a><span class="src-doc">&nbsp;*&nbsp;At&nbsp;least&nbsp;are&nbsp;required&nbsp;both&nbsp;PHP&nbsp;5&nbsp;and&nbsp;MySQL&nbsp;5.</span></div></li>
<li><div class="src-line"><a name="a46"></a><span class="src-doc">&nbsp;*&nbsp;</span><span class="src-doc-coretag">@param&nbsp;</span><span class="src-doc">&nbsp;&nbsp;</span><span class="src-doc-type">string&nbsp;</span><span class="src-doc">&nbsp;&nbsp;&nbsp;</span><span class="src-doc-var">$type&nbsp;</span><span class="src-doc">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&quot;php&quot;&nbsp;or&nbsp;&quot;mysql&quot;,&nbsp;by&nbsp;now</span></div></li>
<li><div class="src-line"><a name="a47"></a><span class="src-doc">&nbsp;*&nbsp;</span><span class="src-doc-coretag">@param&nbsp;</span><span class="src-doc">&nbsp;&nbsp;</span><span class="src-doc-type">string&nbsp;</span><span class="src-doc">&nbsp;&nbsp;&nbsp;</span><span class="src-doc-var">$minReqVer&nbsp;</span><span class="src-doc">&nbsp;minimun&nbsp;system&nbsp;version&nbsp;(default:&nbsp;5.0.0)</span></div></li>
<li><div class="src-line"><a name="a48"></a><span class="src-doc">&nbsp;*&nbsp;</span><span class="src-doc-coretag">@return&nbsp;</span><span class="src-doc">&nbsp;</span><span class="src-doc-type">boolean&nbsp;</span><span class="src-doc">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;TRUE&nbsp;on&nbsp;sucess,&nbsp;or&nbsp;FALSE&nbsp;on&nbsp;failure</span></div></li>
<li><div class="src-line"><a name="a49"></a><span class="src-doc">&nbsp;*/</span></div></li>
<li><div class="src-line"><a name="a50"></a><span class="src-key">function&nbsp;</span><a href="../smt2/_functions.php.html#functioncheck_systemversion">check_systemversion</a><span class="src-sym">(</span><span class="src-var">$type</span><span class="src-sym">,&nbsp;</span><span class="src-var">$minReqVer&nbsp;</span>=&nbsp;<span class="src-str">&quot;5.0.0&quot;</span><span class="src-sym">)&nbsp;</span></div></li>
<li><div class="src-line"><a name="a51"></a><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a52"></a>&nbsp;&nbsp;<span class="src-key">switch&nbsp;</span><span class="src-sym">(</span><a href="http://www.php.net/strtolower">strtolower</a><span class="src-sym">(</span><span class="src-var">$type</span><span class="src-sym">))&nbsp;</span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a53"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-key">case&nbsp;</span><span class="src-str">'mysql'</span>:</div></li>
<li><div class="src-line"><a name="a54"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$ver&nbsp;</span>=&nbsp;<a href="http://www.php.net/mysql_get_client_info">mysql_get_client_info</a><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a55"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-key">break</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a56"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-key">case&nbsp;</span><span class="src-str">'php'</span>:</div></li>
<li><div class="src-line"><a name="a57"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$ver&nbsp;</span>=&nbsp;<a href="http://www.php.net/phpversion">phpversion</a><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a58"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-key">break</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a59"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-key">default</span>:</div></li>
<li><div class="src-line"><a name="a60"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-key">break</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a61"></a>&nbsp;&nbsp;<span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a62"></a>&nbsp;&nbsp;<span class="src-comm">//&nbsp;$ver&nbsp;must&nbsp;be&nbsp;&gt;=&nbsp;$minReqVer</span></div></li>
<li><div class="src-line"><a name="a63"></a>&nbsp;&nbsp;<span class="src-var">$status&nbsp;</span>=&nbsp;<a href="http://www.php.net/version_compare">version_compare</a><span class="src-sym">(</span><span class="src-var">$ver</span><span class="src-sym">,&nbsp;</span><span class="src-var">$minReqVer</span><span class="src-sym">,&nbsp;</span><span class="src-str">&quot;&gt;=&quot;</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a64"></a>&nbsp;&nbsp;</div></li>
<li><div class="src-line"><a name="a65"></a>&nbsp;&nbsp;<span class="src-key">return&nbsp;</span><span class="src-var">$status</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a66"></a><span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a67"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a68"></a><span class="src-doc">/**&nbsp;</span></div></li>
<li><div class="src-line"><a name="a69"></a><span class="src-doc">&nbsp;*&nbsp;Checks&nbsp;if&nbsp;a&nbsp;new&nbsp;smt2&nbsp;version&nbsp;is&nbsp;released.</span></div></li>
<li><div class="src-line"><a name="a70"></a><span class="src-doc">&nbsp;*&nbsp;</span><span class="src-doc-coretag">@return&nbsp;</span><span class="src-doc">&nbsp;</span><span class="src-doc-type">int&nbsp;</span><span class="src-doc">&nbsp;&nbsp;Server&nbsp;response:&nbsp;1&nbsp;(up&nbsp;to&nbsp;date),&nbsp;2&nbsp;(new&nbsp;version&nbsp;found),&nbsp;3&nbsp;(minor&nbsp;build&nbsp;released),&nbsp;0&nbsp;(connection&nbsp;error),&nbsp;-1&nbsp;(parsing&nbsp;error)</span></div></li>
<li><div class="src-line"><a name="a71"></a><span class="src-doc">&nbsp;*/</span></div></li>
<li><div class="src-line"><a name="a72"></a><span class="src-key">function&nbsp;</span><a href="../smt2/_functions.php.html#functionget_smt_releases">get_smt_releases</a><span class="src-sym">(</span><span class="src-sym">)</span></div></li>
<li><div class="src-line"><a name="a73"></a><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a74"></a>&nbsp;&nbsp;<span class="src-comm">//&nbsp;connect&nbsp;to&nbsp;Web&nbsp;Service</span></div></li>
<li><div class="src-line"><a name="a75"></a>&nbsp;&nbsp;<span class="src-var">$ws&nbsp;</span>=&nbsp;<a href="../smt2/_functions.php.html#functionget_remote_webpage">get_remote_webpage</a><span class="src-sym">(</span><span class="src-str">&quot;http://smt.speedzinemedia.com/smt/versioncheck.php?v=&quot;</span>.<span class="src-id"><a href="../smt2/_define.php.html#defineSMT_VERSION">SMT_VERSION</a></span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a76"></a>&nbsp;&nbsp;</div></li>
<li><div class="src-line"><a name="a77"></a>&nbsp;&nbsp;<span class="src-key">return&nbsp;</span><span class="src-var">$ws</span><span class="src-sym">[</span><span class="src-str">'content'</span><span class="src-sym">]</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a78"></a><span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a79"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a80"></a><span class="src-doc">/**&nbsp;</span></div></li>
<li><div class="src-line"><a name="a81"></a><span class="src-doc">&nbsp;*&nbsp;Displays&nbsp;a&nbsp;message&nbsp;about&nbsp;the&nbsp;installed&nbsp;smt2&nbsp;version.</span></div></li>
<li><div class="src-line"><a name="a82"></a><span class="src-doc">&nbsp;*&nbsp;</span><span class="src-doc-coretag">@return&nbsp;</span><span class="src-doc">&nbsp;</span><span class="src-doc-type">string&nbsp;</span><span class="src-doc">&nbsp;&nbsp;Message</span></div></li>
<li><div class="src-line"><a name="a83"></a><span class="src-doc">&nbsp;*/</span></div></li>
<li><div class="src-line"><a name="a84"></a><span class="src-key">function&nbsp;</span><a href="../smt2/_functions.php.html#functioncheck_smt_releases">check_smt_releases</a><span class="src-sym">(</span><span class="src-sym">)</span></div></li>
<li><div class="src-line"><a name="a85"></a><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a86"></a>&nbsp;&nbsp;<span class="src-key">global&nbsp;</span><a href="../smt2/_messages.php.html#global$_displayType">$_displayType</a><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a87"></a>&nbsp;&nbsp;</div></li>
<li><div class="src-line"><a name="a88"></a>&nbsp;&nbsp;<span class="src-var">$dwnurl&nbsp;</span>=&nbsp;<span class="src-str">&quot;http://smt.speedzinemedia.com/smt/downloads.php&quot;</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a89"></a>&nbsp;&nbsp;</div></li>
<li><div class="src-line"><a name="a90"></a>&nbsp;&nbsp;<span class="src-var">$code&nbsp;</span>=&nbsp;<a href="../smt2/_functions.php.html#functionget_smt_releases">get_smt_releases</a><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a91"></a>&nbsp;&nbsp;</div></li>
<li><div class="src-line"><a name="a92"></a>&nbsp;&nbsp;<span class="src-key">switch&nbsp;</span><span class="src-sym">(</span><span class="src-var">$code</span><span class="src-sym">)&nbsp;</span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a93"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-key">case&nbsp;</span>-<span class="src-num">1</span>:&nbsp;&nbsp;<span class="src-comm">//&nbsp;parsing/reading&nbsp;error</span></div></li>
<li><div class="src-line"><a name="a94"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$type&nbsp;</span>=&nbsp;<span class="src-var">$_displayType</span><span class="src-sym">[</span><span class="src-str">&quot;ERROR&quot;</span><span class="src-sym">]</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a95"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$text&nbsp;</span>=&nbsp;<span class="src-str">'Error&nbsp;while&nbsp;retrieving&nbsp;new&nbsp;(smt)&lt;sup&gt;2&lt;/sup&gt;&nbsp;releases.'</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a96"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-key">break</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a97"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-key">case&nbsp;</span><span class="src-num">0</span>:&nbsp;&nbsp;&nbsp;<span class="src-comm">//&nbsp;connection&nbsp;error</span></div></li>
<li><div class="src-line"><a name="a98"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-key">default</span>:</div></li>
<li><div class="src-line"><a name="a99"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$type&nbsp;</span>=&nbsp;<span class="src-var">$_displayType</span><span class="src-sym">[</span><span class="src-str">&quot;ERROR&quot;</span><span class="src-sym">]</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a100"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$text&nbsp;</span>=&nbsp;<span class="src-str">'Could&nbsp;not&nbsp;find&nbsp;new&nbsp;(smt)&lt;sup&gt;2&lt;/sup&gt;&nbsp;releases.&nbsp;If&nbsp;your&nbsp;Internet&nbsp;connection&nbsp;is&nbsp;OK,&nbsp;maybe&nbsp;the&nbsp;server&nbsp;is&nbsp;temporarily&nbsp;down.'</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a101"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-key">break</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a102"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-key">case&nbsp;</span><span class="src-num">1</span>:&nbsp;&nbsp;&nbsp;<span class="src-comm">//&nbsp;up&nbsp;to&nbsp;date</span></div></li>
<li><div class="src-line"><a name="a103"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$type&nbsp;</span>=&nbsp;<span class="src-var">$_displayType</span><span class="src-sym">[</span><span class="src-str">&quot;SUCCESS&quot;</span><span class="src-sym">]</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a104"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$text&nbsp;</span>=&nbsp;<span class="src-str">'You&nbsp;are&nbsp;using&nbsp;the&nbsp;latest&nbsp;(smt)&lt;sup&gt;2&lt;/sup&gt;&nbsp;version:&nbsp;'</span>.<span class="src-id"><a href="../smt2/_define.php.html#defineSMT_VERSION">SMT_VERSION</a></span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a105"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-key">break</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a106"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-key">case&nbsp;</span><span class="src-num">2</span>:&nbsp;&nbsp;&nbsp;<span class="src-comm">//&nbsp;new&nbsp;version&nbsp;found</span></div></li>
<li><div class="src-line"><a name="a107"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$type&nbsp;</span>=&nbsp;<span class="src-var">$_displayType</span><span class="src-sym">[</span><span class="src-str">&quot;WARNING&quot;</span><span class="src-sym">]</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a108"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$text&nbsp;</span>=&nbsp;<span class="src-str">'A&nbsp;new&nbsp;(smt)&lt;sup&gt;2&lt;/sup&gt;&nbsp;version&nbsp;is&nbsp;available.&nbsp;&lt;a&nbsp;href=&quot;'</span>.<span class="src-var">$dwnurl</span>.<span class="src-str">'&quot;&gt;Please&nbsp;upgrade&lt;/a&gt;.'</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a109"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-key">break</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a110"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-key">case&nbsp;</span><span class="src-num">3</span>:&nbsp;&nbsp;&nbsp;<span class="src-comm">//&nbsp;minor&nbsp;build&nbsp;released</span></div></li>
<li><div class="src-line"><a name="a111"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$type&nbsp;</span>=&nbsp;<span class="src-var">$_displayType</span><span class="src-sym">[</span><span class="src-str">&quot;WARNING&quot;</span><span class="src-sym">]</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a112"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$text&nbsp;</span>=&nbsp;<span class="src-str">'It&nbsp;seems&nbsp;that&nbsp;there&nbsp;is&nbsp;a&nbsp;&lt;a&nbsp;href=&quot;'</span>.<span class="src-var">$dwnurl</span>.<span class="src-str">'&quot;&gt;new&nbsp;(smt)&lt;sup&gt;2&lt;/sup&gt;&nbsp;build&nbsp;available&lt;/a&gt;.'</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a113"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-key">break</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a114"></a>&nbsp;&nbsp;<span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a115"></a>&nbsp;&nbsp;</div></li>
<li><div class="src-line"><a name="a116"></a>&nbsp;&nbsp;<span class="src-key">return&nbsp;</span><a href="../smt2/_functions.php.html#functiondisplay_text">display_text</a><span class="src-sym">(</span><span class="src-var">$type</span><span class="src-sym">,&nbsp;</span><span class="src-var">$text</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a117"></a><span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a118"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a119"></a><span class="src-doc">/**</span></div></li>
<li><div class="src-line"><a name="a120"></a><span class="src-doc">&nbsp;*&nbsp;Displays&nbsp;a&nbsp;text&nbsp;paragraph&nbsp;on&nbsp;page.</span></div></li>
<li><div class="src-line"><a name="a121"></a><span class="src-doc">&nbsp;*&nbsp;</span><span class="src-doc-coretag">@param&nbsp;</span><span class="src-doc">&nbsp;&nbsp;</span><span class="src-doc-type">string&nbsp;</span><span class="src-doc">&nbsp;&nbsp;&nbsp;</span><span class="src-doc-var">$type&nbsp;</span><span class="src-doc">&quot;warning&quot;,&nbsp;&quot;error&quot;&nbsp;or&nbsp;&quot;success&quot;</span></div></li>
<li><div class="src-line"><a name="a122"></a><span class="src-doc">&nbsp;*&nbsp;</span><span class="src-doc-coretag">@param&nbsp;</span><span class="src-doc">&nbsp;&nbsp;</span><span class="src-doc-type">string&nbsp;</span><span class="src-doc">&nbsp;&nbsp;&nbsp;</span><span class="src-doc-var">$msg&nbsp;</span><span class="src-doc">&nbsp;message&nbsp;to&nbsp;display</span></div></li>
<li><div class="src-line"><a name="a123"></a><span class="src-doc">&nbsp;*&nbsp;</span><span class="src-doc-coretag">@param&nbsp;</span><span class="src-doc">&nbsp;&nbsp;</span><span class="src-doc-type">string&nbsp;</span><span class="src-doc">&nbsp;&nbsp;&nbsp;</span><span class="src-doc-var">$elem&nbsp;</span><span class="src-doc">DOM&nbsp;element&nbsp;to&nbsp;enclose&nbsp;message&nbsp;(default:&nbsp;p)</span></div></li>
<li><div class="src-line"><a name="a124"></a><span class="src-doc">&nbsp;*/</span></div></li>
<li><div class="src-line"><a name="a125"></a><span class="src-key">function&nbsp;</span><a href="../smt2/_functions.php.html#functiondisplay_text">display_text</a><span class="src-sym">(</span><span class="src-var">$type</span><span class="src-sym">,&nbsp;</span><span class="src-var">$msg</span><span class="src-sym">,&nbsp;</span><span class="src-var">$elem&nbsp;</span>=&nbsp;<span class="src-str">'p'</span><span class="src-sym">)</span></div></li>
<li><div class="src-line"><a name="a126"></a><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a127"></a>&nbsp;&nbsp;<span class="src-key">return&nbsp;</span><span class="src-str">'&lt;'</span>.<span class="src-var">$elem</span>.<span class="src-str">'&nbsp;class=&quot;'</span>.<span class="src-var">$type</span>.<span class="src-str">'&quot;&gt;'</span>.<span class="src-var">$msg</span>.<span class="src-str">'&lt;/'</span>.<span class="src-var">$elem</span>.<span class="src-str">'&gt;'</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a128"></a><span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a129"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a130"></a><span class="src-doc">/**</span></div></li>
<li><div class="src-line"><a name="a131"></a><span class="src-doc">&nbsp;*&nbsp;Redirects&nbsp;the&nbsp;browser&nbsp;to&nbsp;a&nbsp;specified&nbsp;anchor&nbsp;on&nbsp;the&nbsp;page&nbsp;that&nbsp;sent&nbsp;a&nbsp;form.</span></div></li>
<li><div class="src-line"><a name="a132"></a><span class="src-doc">&nbsp;*&nbsp;</span><span class="src-doc-coretag">@param&nbsp;</span><span class="src-doc">&nbsp;&nbsp;</span><span class="src-doc-type">string&nbsp;</span><span class="src-doc">&nbsp;&nbsp;&nbsp;</span><span class="src-doc-var">$id&nbsp;</span><span class="src-doc">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;HTML&nbsp;element&nbsp;id</span></div></li>
<li><div class="src-line"><a name="a133"></a><span class="src-doc">&nbsp;*&nbsp;</span><span class="src-doc-coretag">@param&nbsp;</span><span class="src-doc">&nbsp;&nbsp;</span><span class="src-doc-type">boolean&nbsp;</span><span class="src-doc">&nbsp;&nbsp;</span><span class="src-doc-var">$success&nbsp;</span><span class="src-doc">&nbsp;&nbsp;&nbsp;no&nbsp;errors&nbsp;to&nbsp;display</span></div></li>
<li><div class="src-line"><a name="a134"></a><span class="src-doc">&nbsp;*&nbsp;</span><span class="src-doc-coretag">@param&nbsp;</span><span class="src-doc">&nbsp;&nbsp;</span><span class="src-doc-type">string&nbsp;</span><span class="src-doc">&nbsp;&nbsp;&nbsp;</span><span class="src-doc-var">$customErr&nbsp;</span><span class="src-doc">&nbsp;if&nbsp;$success&nbsp;is&nbsp;false,&nbsp;type&nbsp;here&nbsp;your&nbsp;own&nbsp;custom&nbsp;message</span></div></li>
<li><div class="src-line"><a name="a135"></a><span class="src-doc">&nbsp;*/</span></div></li>
<li><div class="src-line"><a name="a136"></a><span class="src-key">function&nbsp;</span><a href="../smt2/_functions.php.html#functionnotify_request">notify_request</a><span class="src-sym">(</span><span class="src-var">$id</span><span class="src-sym">,&nbsp;</span><span class="src-var">$success</span><span class="src-sym">,&nbsp;</span><span class="src-var">$customErr&nbsp;</span>=&nbsp;<span class="src-str">&quot;&quot;</span><span class="src-sym">)</span></div></li>
<li><div class="src-line"><a name="a137"></a><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a138"></a>&nbsp;&nbsp;<span class="src-key">global&nbsp;</span><a href="../smt2/_messages.php.html#global$_displayType">$_displayType</a><span class="src-sym">,&nbsp;</span><a href="../smt2/_messages.php.html#global$_notifyMsg">$_notifyMsg</a><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a139"></a>&nbsp;&nbsp;</div></li>
<li><div class="src-line"><a name="a140"></a>&nbsp;&nbsp;<span class="src-var">$errorMessage&nbsp;</span>=&nbsp;<span class="src-var">$_notifyMsg</span><span class="src-sym">[</span><span class="src-str">&quot;ERROR&quot;</span><span class="src-sym">]</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a141"></a>&nbsp;&nbsp;<span class="src-key">if&nbsp;</span><span class="src-sym">(</span><span class="src-sym">!</span><span class="src-var">$success&nbsp;</span>&amp;&amp;&nbsp;<span class="src-sym">!</span><span class="src-key">empty</span><span class="src-sym">(</span><span class="src-var">$customErr</span><span class="src-sym">))&nbsp;</span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a142"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$errorMessage&nbsp;</span>=&nbsp;<span class="src-var">$customErr</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a143"></a>&nbsp;&nbsp;<span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a144"></a>&nbsp;&nbsp;</div></li>
<li><div class="src-line"><a name="a145"></a>&nbsp;&nbsp;<span class="src-var">$_SESSION</span><span class="src-sym">[&nbsp;</span><span class="src-var">$id&nbsp;</span><span class="src-sym">]&nbsp;</span>=&nbsp;<span class="src-sym">(</span><span class="src-var">$success</span><span class="src-sym">)&nbsp;</span>?&nbsp;</div></li>
<li><div class="src-line"><a name="a146"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="../smt2/_functions.php.html#functiondisplay_text">display_text</a><span class="src-sym">(</span><span class="src-var">$_displayType</span><span class="src-sym">[</span><span class="src-str">&quot;SUCCESS&quot;</span><span class="src-sym">]</span><span class="src-sym">,&nbsp;</span><span class="src-var">$_notifyMsg</span><span class="src-sym">[</span><span class="src-str">&quot;SAVED&quot;</span><span class="src-sym">]</span><span class="src-sym">)</span></div></li>
<li><div class="src-line"><a name="a147"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:</div></li>
<li><div class="src-line"><a name="a148"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="../smt2/_functions.php.html#functiondisplay_text">display_text</a><span class="src-sym">(</span><span class="src-var">$_displayType</span><span class="src-sym">[</span><span class="src-str">&quot;ERROR&quot;</span><span class="src-sym">]</span><span class="src-sym">,&nbsp;&nbsp;&nbsp;</span><span class="src-var">$errorMessage</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a149"></a>&nbsp;&nbsp;</div></li>
<li><div class="src-line"><a name="a150"></a>&nbsp;&nbsp;<a href="../smt2/_functions.php.html#functionredirect">redirect</a><span class="src-sym">(&nbsp;</span><a href="http://www.php.net/dirname">dirname</a><span class="src-sym">(</span><span class="src-var">$_SERVER</span><span class="src-sym">[</span><span class="src-str">'SCRIPT_NAME'</span><span class="src-sym">]</span><span class="src-sym">)</span>.<span class="src-str">&quot;/#&quot;</span>.<span class="src-var">$id&nbsp;</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a151"></a><span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a152"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a153"></a><span class="src-doc">/**</span></div></li>
<li><div class="src-line"><a name="a154"></a><span class="src-doc">&nbsp;*&nbsp;Displays&nbsp;the&nbsp;message&nbsp;saved&nbsp;on&nbsp;current&nbsp;PHP&nbsp;session.&nbsp;Then&nbsp;the&nbsp;$_SESSION&nbsp;text&nbsp;is&nbsp;unset.</span></div></li>
<li><div class="src-line"><a name="a155"></a><span class="src-doc">&nbsp;*&nbsp;</span><span class="src-doc-coretag">@param&nbsp;</span><span class="src-doc">&nbsp;&nbsp;</span><span class="src-doc-type">string&nbsp;</span><span class="src-doc">&nbsp;</span><span class="src-doc-var">$name&nbsp;</span><span class="src-doc">&nbsp;&nbsp;session&nbsp;variable&nbsp;name</span></div></li>
<li><div class="src-line"><a name="a156"></a><span class="src-doc">&nbsp;*/</span></div></li>
<li><div class="src-line"><a name="a157"></a><span class="src-key">function&nbsp;</span><a href="../smt2/_functions.php.html#functioncheck_notified_request">check_notified_request</a><span class="src-sym">(</span><span class="src-var">$name</span><span class="src-sym">)&nbsp;</span></div></li>
<li><div class="src-line"><a name="a158"></a><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a159"></a>&nbsp;&nbsp;<span class="src-comm">//&nbsp;get&nbsp;$name&nbsp;text&nbsp;from&nbsp;session</span></div></li>
<li><div class="src-line"><a name="a160"></a>&nbsp;&nbsp;<span class="src-key">if&nbsp;</span><span class="src-sym">(</span>isset<span class="src-sym">(</span><span class="src-var">$_SESSION</span><span class="src-sym">[</span><span class="src-var">$name</span><span class="src-sym">]</span><span class="src-sym">))&nbsp;</span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a161"></a>&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;<span class="src-var">$_SESSION</span><span class="src-sym">[</span><span class="src-var">$name</span><span class="src-sym">]</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a162"></a>&nbsp;&nbsp;<span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a163"></a>&nbsp;&nbsp;<span class="src-comm">//&nbsp;unset&nbsp;session&nbsp;var</span></div></li>
<li><div class="src-line"><a name="a164"></a>&nbsp;&nbsp;unset<span class="src-sym">(</span><span class="src-var">$_SESSION</span><span class="src-sym">[</span><span class="src-var">$name</span><span class="src-sym">]</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a165"></a><span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a166"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a167"></a><span class="src-doc">/**&nbsp;</span></div></li>
<li><div class="src-line"><a name="a168"></a><span class="src-doc">&nbsp;*&nbsp;Shows&nbsp;only&nbsp;the&nbsp;first&nbsp;$words&nbsp;of&nbsp;a&nbsp;text,&nbsp;plus&nbsp;a&nbsp;[...]&nbsp;symbol.</span></div></li>
<li><div class="src-line"><a name="a169"></a><span class="src-doc">&nbsp;*&nbsp;</span><span class="src-doc-coretag">@param&nbsp;</span><span class="src-doc">&nbsp;&nbsp;</span><span class="src-doc-type">string&nbsp;</span><span class="src-doc">&nbsp;</span><span class="src-doc-var">$text&nbsp;</span><span class="src-doc">&nbsp;&nbsp;text&nbsp;to&nbsp;trim</span></div></li>
<li><div class="src-line"><a name="a170"></a><span class="src-doc">&nbsp;*&nbsp;</span><span class="src-doc-coretag">@param&nbsp;</span><span class="src-doc">&nbsp;&nbsp;</span><span class="src-doc-type">int&nbsp;</span><span class="src-doc">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="src-doc-var">$words&nbsp;</span><span class="src-doc">&nbsp;number&nbsp;of&nbsp;words&nbsp;to&nbsp;display&nbsp;(default:&nbsp;5)</span></div></li>
<li><div class="src-line"><a name="a171"></a><span class="src-doc">&nbsp;*&nbsp;</span><span class="src-doc-coretag">@return&nbsp;</span><span class="src-doc">&nbsp;</span><span class="src-doc-type">string&nbsp;</span><span class="src-doc">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;The&nbsp;trimmed&nbsp;text</span></div></li>
<li><div class="src-line"><a name="a172"></a><span class="src-doc">&nbsp;*/</span></div></li>
<li><div class="src-line"><a name="a173"></a><span class="src-key">function&nbsp;</span><a href="../smt2/_functions.php.html#functiontrim_text">trim_text</a><span class="src-sym">(</span><span class="src-var">$text</span><span class="src-sym">,&nbsp;</span><span class="src-var">$words&nbsp;</span>=&nbsp;<span class="src-num">5</span><span class="src-sym">)&nbsp;</span></div></li>
<li><div class="src-line"><a name="a174"></a><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a175"></a>&nbsp;&nbsp;<span class="src-var">$space&nbsp;</span>=&nbsp;<span class="src-str">&quot;&nbsp;&quot;</span><span class="src-sym">;&nbsp;&nbsp;</span></div></li>
<li><div class="src-line"><a name="a176"></a>&nbsp;&nbsp;<span class="src-var">$text&nbsp;</span>=&nbsp;<a href="http://www.php.net/explode">explode</a><span class="src-sym">(</span><span class="src-var">$space</span><span class="src-sym">,&nbsp;</span><span class="src-var">$text</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a177"></a>&nbsp;&nbsp;</div></li>
<li><div class="src-line"><a name="a178"></a>&nbsp;&nbsp;<span class="src-var">$show&nbsp;</span>=&nbsp;<span class="src-str">&quot;&quot;</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a179"></a>&nbsp;&nbsp;<span class="src-key">foreach&nbsp;</span><span class="src-sym">(</span><span class="src-var">$text&nbsp;</span><span class="src-key">as&nbsp;</span><span class="src-var">$i&nbsp;</span>=&gt;&nbsp;<span class="src-var">$str</span><span class="src-sym">)&nbsp;</span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a180"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-key">if&nbsp;</span><span class="src-sym">(</span><span class="src-var">$i&nbsp;</span>&lt;&nbsp;<span class="src-var">$words</span><span class="src-sym">)&nbsp;</span><span class="src-sym">{&nbsp;</span></div></li>
<li><div class="src-line"><a name="a181"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$show&nbsp;</span>.=&nbsp;<span class="src-var">$str</span>.<span class="src-var">$space</span><span class="src-sym">;&nbsp;</span></div></li>
<li><div class="src-line"><a name="a182"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a183"></a>&nbsp;&nbsp;<span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a184"></a>&nbsp;&nbsp;<span class="src-comm">//&nbsp;references&nbsp;of&nbsp;$i&nbsp;and&nbsp;the&nbsp;last&nbsp;array&nbsp;element&nbsp;remain&nbsp;</span></div></li>
<li><div class="src-line"><a name="a185"></a>&nbsp;&nbsp;<span class="src-key">if&nbsp;</span><span class="src-sym">(</span><span class="src-var">$i&nbsp;</span>&gt;=&nbsp;<span class="src-var">$words</span><span class="src-sym">)&nbsp;</span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a186"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-comm">//&nbsp;add&nbsp;[...]&nbsp;if&nbsp;word&nbsp;count&nbsp;is&nbsp;indeed&nbsp;larger&nbsp;than&nbsp;$words</span></div></li>
<li><div class="src-line"><a name="a187"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$show&nbsp;</span>.=&nbsp;<span class="src-var">$space</span>.<span class="src-str">&quot;[...]&quot;</span><span class="src-sym">;&nbsp;</span></div></li>
<li><div class="src-line"><a name="a188"></a>&nbsp;&nbsp;<span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a189"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a190"></a>&nbsp;&nbsp;<span class="src-key">return&nbsp;</span><span class="src-var">$show</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a191"></a><span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a192"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a193"></a><span class="src-doc">/**&nbsp;</span></div></li>
<li><div class="src-line"><a name="a194"></a><span class="src-doc">&nbsp;*&nbsp;Assigns&nbsp;an&nbsp;unique&nbsp;identifier&nbsp;for&nbsp;each&nbsp;client&nbsp;machine.</span></div></li>
<li><div class="src-line"><a name="a195"></a><span class="src-doc">&nbsp;*&nbsp;</span><span class="src-doc-coretag">@return&nbsp;</span><span class="src-doc">&nbsp;</span><span class="src-doc-type">string&nbsp;</span><span class="src-doc">&nbsp;&nbsp;&nbsp;Encoded&nbsp;client&nbsp;identifier</span></div></li>
<li><div class="src-line"><a name="a196"></a><span class="src-doc">&nbsp;*/</span></div></li>
<li><div class="src-line"><a name="a197"></a><span class="src-key">function&nbsp;</span><a href="../smt2/_functions.php.html#functionget_client_id">get_client_id</a><span class="src-sym">(</span><span class="src-sym">)</span></div></li>
<li><div class="src-line"><a name="a198"></a><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a199"></a>&nbsp;&nbsp;&nbsp;<span class="src-key">if</span><span class="src-sym">(&nbsp;</span><span class="src-sym">!</span><span class="src-key">empty</span><span class="src-sym">(</span><span class="src-var">$_SERVER</span><span class="src-sym">[</span><span class="src-str">'HTTP_X_FORWARDED_FOR'</span><span class="src-sym">]</span><span class="src-sym">)&nbsp;)&nbsp;</span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a200"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$client_id&nbsp;</span>=</div></li>
<li><div class="src-line"><a name="a201"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-sym">(&nbsp;</span><span class="src-sym">!</span><span class="src-key">empty</span><span class="src-sym">(</span><span class="src-var">$_SERVER</span><span class="src-sym">[</span><span class="src-str">'REMOTE_ADDR'</span><span class="src-sym">]</span><span class="src-sym">)&nbsp;)&nbsp;</span>?</div></li>
<li><div class="src-line"><a name="a202"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$_SERVER</span><span class="src-sym">[</span><span class="src-str">'REMOTE_ADDR'</span><span class="src-sym">]&nbsp;</span>:</div></li>
<li><div class="src-line"><a name="a203"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-sym">(&nbsp;(&nbsp;</span><span class="src-sym">!</span><span class="src-key">empty</span><span class="src-sym">(</span><span class="src-var">$_ENV</span><span class="src-sym">[</span><span class="src-str">'REMOTE_ADDR'</span><span class="src-sym">]</span><span class="src-sym">)&nbsp;)&nbsp;</span>?</div></li>
<li><div class="src-line"><a name="a204"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$_ENV</span><span class="src-sym">[</span><span class="src-str">'REMOTE_ADDR'</span><span class="src-sym">]&nbsp;</span>:</div></li>
<li><div class="src-line"><a name="a205"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-str">&quot;unknown&quot;&nbsp;</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a206"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$entries&nbsp;</span>=&nbsp;<a href="http://www.php.net/split">split</a><span class="src-sym">(</span><span class="src-str">'[,&nbsp;]'</span><span class="src-sym">,&nbsp;</span><span class="src-var">$_SERVER</span><span class="src-sym">[</span><span class="src-str">'HTTP_X_FORWARDED_FOR'</span><span class="src-sym">]</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a207"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="http://www.php.net/reset">reset</a><span class="src-sym">(</span><span class="src-var">$entries</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a208"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-key">while&nbsp;</span><span class="src-sym">(</span>list<span class="src-sym">(</span><span class="src-sym">,&nbsp;</span><span class="src-var">$entry</span><span class="src-sym">)&nbsp;</span>=&nbsp;<a href="http://www.php.net/each">each</a><span class="src-sym">(</span><span class="src-var">$entries</span><span class="src-sym">))&nbsp;</span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a209"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$entry&nbsp;</span>=&nbsp;<a href="http://www.php.net/trim">trim</a><span class="src-sym">(</span><span class="src-var">$entry</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a210"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-key">if&nbsp;</span><span class="src-sym">(&nbsp;</span><a href="http://www.php.net/preg_match">preg_match</a><span class="src-sym">(</span><span class="src-str">&quot;/^([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)/&quot;</span><span class="src-sym">,&nbsp;</span><span class="src-var">$entry</span><span class="src-sym">,&nbsp;</span><span class="src-var">$id_list</span><span class="src-sym">)&nbsp;)&nbsp;</span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a211"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-comm">//&nbsp;see&nbsp;http://www.faqs.org/rfcs/rfc1918.html</span></div></li>
<li><div class="src-line"><a name="a212"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$private_id&nbsp;</span>=&nbsp;<span class="src-key">array</span><span class="src-sym">(</span></div></li>
<li><div class="src-line"><a name="a213"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-str">'/^0\./'</span><span class="src-sym">,</span></div></li>
<li><div class="src-line"><a name="a214"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-str">'/^127\.0\.0\.1/'</span><span class="src-sym">,</span></div></li>
<li><div class="src-line"><a name="a215"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-str">'/^192\.168\..*/'</span><span class="src-sym">,</span></div></li>
<li><div class="src-line"><a name="a216"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-str">'/^172\.((1[6-9])|(2[0-9])|(3[0-1]))\..*/'</span><span class="src-sym">,</span></div></li>
<li><div class="src-line"><a name="a217"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-str">'/^10\..*/'</span></div></li>
<li><div class="src-line"><a name="a218"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a219"></a>&nbsp;&nbsp;&nbsp;</div></li>
<li><div class="src-line"><a name="a220"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$found_id&nbsp;</span>=&nbsp;<a href="http://www.php.net/preg_replace">preg_replace</a><span class="src-sym">(</span><span class="src-var">$private_id</span><span class="src-sym">,&nbsp;</span><span class="src-var">$client_id</span><span class="src-sym">,&nbsp;</span><span class="src-var">$id_list</span><span class="src-sym">[</span><span class="src-num">1</span><span class="src-sym">]</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a221"></a>&nbsp;&nbsp;&nbsp;</div></li>
<li><div class="src-line"><a name="a222"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-key">if&nbsp;</span><span class="src-sym">(</span><span class="src-var">$client_id&nbsp;</span>!=&nbsp;<span class="src-var">$found_id</span><span class="src-sym">)&nbsp;</span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a223"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$client_id&nbsp;</span>=&nbsp;<span class="src-var">$found_id</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a224"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-key">break</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a225"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a226"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a227"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a228"></a>&nbsp;&nbsp;&nbsp;<span class="src-sym">}&nbsp;</span><span class="src-key">else&nbsp;</span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a229"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$client_id&nbsp;</span>=</div></li>
<li><div class="src-line"><a name="a230"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-sym">(&nbsp;</span><span class="src-sym">!</span><span class="src-key">empty</span><span class="src-sym">(</span><span class="src-var">$_SERVER</span><span class="src-sym">[</span><span class="src-str">'REMOTE_ADDR'</span><span class="src-sym">]</span><span class="src-sym">)&nbsp;)&nbsp;</span>?</div></li>
<li><div class="src-line"><a name="a231"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$_SERVER</span><span class="src-sym">[</span><span class="src-str">'REMOTE_ADDR'</span><span class="src-sym">]&nbsp;</span>:</div></li>
<li><div class="src-line"><a name="a232"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-sym">(&nbsp;(&nbsp;</span><span class="src-sym">!</span><span class="src-key">empty</span><span class="src-sym">(</span><span class="src-var">$_ENV</span><span class="src-sym">[</span><span class="src-str">'REMOTE_ADDR'</span><span class="src-sym">]</span><span class="src-sym">)&nbsp;)&nbsp;</span>?</div></li>
<li><div class="src-line"><a name="a233"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$_ENV</span><span class="src-sym">[</span><span class="src-str">'REMOTE_ADDR'</span><span class="src-sym">]&nbsp;</span>:</div></li>
<li><div class="src-line"><a name="a234"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-str">&quot;unknown&quot;&nbsp;</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a235"></a>&nbsp;&nbsp;&nbsp;<span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a236"></a>&nbsp;&nbsp;&nbsp;</div></li>
<li><div class="src-line"><a name="a237"></a>&nbsp;&nbsp;&nbsp;<span class="src-key">return&nbsp;</span><a href="http://www.php.net/base64_encode">base64_encode</a><span class="src-sym">(</span><span class="src-var">$client_id</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a238"></a><span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a239"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a240"></a><span class="src-doc">/**&nbsp;</span></div></li>
<li><div class="src-line"><a name="a241"></a><span class="src-doc">&nbsp;*&nbsp;Masks&nbsp;a&nbsp;given&nbsp;client&nbsp;ID&nbsp;string.</span></div></li>
<li><div class="src-line"><a name="a242"></a><span class="src-doc">&nbsp;*&nbsp;</span><span class="src-doc-coretag">@param&nbsp;</span><span class="src-doc">&nbsp;</span><span class="src-doc-type">string&nbsp;</span><span class="src-doc">&nbsp;&nbsp;</span><span class="src-doc-var">$id&nbsp;</span><span class="src-doc">&nbsp;&nbsp;client&nbsp;ID</span></div></li>
<li><div class="src-line"><a name="a243"></a><span class="src-doc">&nbsp;*&nbsp;</span><span class="src-doc-coretag">@return&nbsp;</span><span class="src-doc-type">string&nbsp;</span><span class="src-doc">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Pretty-formatted&nbsp;client&nbsp;ID</span></div></li>
<li><div class="src-line"><a name="a244"></a><span class="src-doc">&nbsp;*/</span></div></li>
<li><div class="src-line"><a name="a245"></a><span class="src-key">function&nbsp;</span><a href="../smt2/_functions.php.html#functionmask_client">mask_client</a><span class="src-sym">(</span><span class="src-var">$id</span><span class="src-sym">)</span></div></li>
<li><div class="src-line"><a name="a246"></a><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a247"></a>&nbsp;&nbsp;<span class="src-var">$hash&nbsp;</span>=&nbsp;<a href="http://www.php.net/md5">md5</a><span class="src-sym">(</span><span class="src-var">$id</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a248"></a>&nbsp;&nbsp;<span class="src-var">$half&nbsp;</span>=&nbsp;<a href="http://www.php.net/strlen">strlen</a><span class="src-sym">(</span><span class="src-var">$hash</span><span class="src-sym">)&nbsp;</span>/&nbsp;<span class="src-num">2</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a249"></a>&nbsp;&nbsp;</div></li>
<li><div class="src-line"><a name="a250"></a>&nbsp;&nbsp;<span class="src-key">return&nbsp;</span><a href="http://www.php.net/substr">substr</a><span class="src-sym">(</span><span class="src-var">$hash</span><span class="src-sym">,&nbsp;</span>-<span class="src-var">$half</span><span class="src-sym">,&nbsp;</span><span class="src-var">$half</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a251"></a><span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a252"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a253"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a254"></a><span class="src-doc">/**&nbsp;</span></div></li>
<li><div class="src-line"><a name="a255"></a><span class="src-doc">&nbsp;*&nbsp;Gets&nbsp;URL&nbsp;contents&nbsp;within&nbsp;the&nbsp;HTTP&nbsp;server&nbsp;response&nbsp;header&nbsp;fields.</span></div></li>
<li><div class="src-line"><a name="a256"></a><span class="src-doc">&nbsp;*&nbsp;This&nbsp;function&nbsp;uses&nbsp;cURL&nbsp;to&nbsp;fetch&nbsp;remote&nbsp;pages.</span></div></li>
<li><div class="src-line"><a name="a257"></a><span class="src-doc">&nbsp;*&nbsp;</span><span class="src-doc-coretag">@param&nbsp;</span><span class="src-doc">&nbsp;</span><span class="src-doc-type">string&nbsp;</span><span class="src-doc">&nbsp;&nbsp;</span><span class="src-doc-var">$URL&nbsp;</span><span class="src-doc">&nbsp;&nbsp;web&nbsp;page&nbsp;URL</span></div></li>
<li><div class="src-line"><a name="a258"></a><span class="src-doc">&nbsp;*&nbsp;</span><span class="src-doc-coretag">@param&nbsp;</span><span class="src-doc">&nbsp;</span><span class="src-doc-type">array&nbsp;</span><span class="src-doc">&nbsp;&nbsp;&nbsp;</span><span class="src-doc-var">$opts&nbsp;</span><span class="src-doc">&nbsp;custom&nbsp;cURL&nbsp;options</span></div></li>
<li><div class="src-line"><a name="a259"></a><span class="src-doc">&nbsp;*&nbsp;</span><span class="src-doc-coretag">@return&nbsp;</span><span class="src-doc-type">array&nbsp;</span><span class="src-doc">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Transfer&nbsp;information&nbsp;(the&nbsp;web&nbsp;page&nbsp;content&nbsp;is&nbsp;in&nbsp;the&nbsp;&quot;content&quot;&nbsp;array&nbsp;key)</span></div></li>
<li><div class="src-line"><a name="a260"></a><span class="src-doc">&nbsp;*&nbsp;</span><span class="src-doc-coretag">@link</span><span class="src-doc">&nbsp;&nbsp;http://es2.php.net/manual/en/curl.constants.php</span></div></li>
<li><div class="src-line"><a name="a261"></a><span class="src-doc">&nbsp;*&nbsp;</span><span class="src-doc-coretag">@link</span><span class="src-doc">&nbsp;&nbsp;http://es2.php.net/manual/en/function.curl-setopt.php</span></div></li>
<li><div class="src-line"><a name="a262"></a><span class="src-doc">&nbsp;*/</span></div></li>
<li><div class="src-line"><a name="a263"></a><span class="src-key">function&nbsp;</span><a href="../smt2/_functions.php.html#functionget_remote_webpage">get_remote_webpage</a><span class="src-sym">(</span><span class="src-var">$URL</span><span class="src-sym">,&nbsp;</span><span class="src-var">$opts&nbsp;</span>=&nbsp;<span class="src-key">array</span><span class="src-sym">(</span><span class="src-sym">))</span></div></li>
<li><div class="src-line"><a name="a264"></a><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a265"></a>&nbsp;&nbsp;<span class="src-comm">//&nbsp;basic&nbsp;options&nbsp;(regular&nbsp;GET&nbsp;requests)</span></div></li>
<li><div class="src-line"><a name="a266"></a>&nbsp;&nbsp;<span class="src-var">$options&nbsp;</span>=&nbsp;<span class="src-key">array</span><span class="src-sym">(</span></div></li>
<li><div class="src-line"><a name="a267"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-id">CURLOPT_URL&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>=&gt;&nbsp;<span class="src-var">$URL</span><span class="src-sym">,</span></div></li>
<li><div class="src-line"><a name="a268"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-id">CURLOPT_USERAGENT&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>=&gt;&nbsp;<span class="src-var">$_SERVER</span><span class="src-sym">[</span><span class="src-str">'HTTP_USER_AGENT'</span><span class="src-sym">]</span><span class="src-sym">,</span></div></li>
<li><div class="src-line"><a name="a269"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-id">CURLOPT_RETURNTRANSFER&nbsp;</span>=&gt;&nbsp;<span class="src-id">true</span><span class="src-sym">,&nbsp;&nbsp;&nbsp;</span><span class="src-comm">//&nbsp;return&nbsp;transfer&nbsp;as&nbsp;a&nbsp;string</span></div></li>
<li><div class="src-line"><a name="a270"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-id">CURLOPT_HEADER&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>=&gt;&nbsp;<span class="src-id">false</span><span class="src-sym">,&nbsp;&nbsp;</span><span class="src-comm">//&nbsp;don't&nbsp;return&nbsp;headers</span></div></li>
<li><div class="src-line"><a name="a271"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-id">CURLOPT_ENCODING&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>=&gt;&nbsp;<span class="src-str">&quot;&quot;</span><span class="src-sym">,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="src-comm">//&nbsp;handle&nbsp;all&nbsp;encodings</span></div></li>
<li><div class="src-line"><a name="a272"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-id">CURLOPT_CONNECTTIMEOUT&nbsp;</span>=&gt;&nbsp;<span class="src-num">10</span><span class="src-sym">,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="src-comm">//&nbsp;timeout&nbsp;on&nbsp;connect</span></div></li>
<li><div class="src-line"><a name="a273"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-id">CURLOPT_TIMEOUT&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>=&gt;&nbsp;<span class="src-num">60</span><span class="src-sym">,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="src-comm">//&nbsp;timeout&nbsp;on&nbsp;response</span></div></li>
<li><div class="src-line"><a name="a274"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-id">CURLOPT_SSL_VERIFYPEER&nbsp;</span>=&gt;&nbsp;<span class="src-id">false</span><span class="src-sym">,&nbsp;&nbsp;</span><span class="src-comm">//&nbsp;try&nbsp;to&nbsp;fetch&nbsp;SSL&nbsp;pages&nbsp;too</span></div></li>
<li><div class="src-line"><a name="a275"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-id">CURLOPT_SSL_VERIFYHOST&nbsp;</span>=&gt;&nbsp;<span class="src-id">false</span></div></li>
<li><div class="src-line"><a name="a276"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a277"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a278"></a>&nbsp;&nbsp;<span class="src-comm">/*&nbsp;cURL&nbsp;should&nbsp;follow&nbsp;redirections!&nbsp;</span></div></li>
<li><div class="src-line"><a name="a279"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;*&nbsp;But&nbsp;safe&nbsp;mode&nbsp;(deprecated)&nbsp;and&nbsp;open_basedir&nbsp;(useless)&nbsp;are&nbsp;incompatible</span></div></li>
<li><div class="src-line"><a name="a280"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;*&nbsp;with&nbsp;CURLOPT_FOLLOWLOCATION.</span></div></li>
<li><div class="src-line"><a name="a281"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;*&nbsp;Also&nbsp;see&nbsp;this&nbsp;solution:&nbsp;http://www.php.net/manual/en/function.curl-setopt.php#71313&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></div></li>
<li><div class="src-line"><a name="a282"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;*/</span></div></li>
<li><div class="src-line"><a name="a283"></a>&nbsp;&nbsp;<span class="src-key">if&nbsp;</span><span class="src-sym">(</span><span class="src-sym">!</span><a href="http://www.php.net/ini_get">ini_get</a><span class="src-sym">(</span><span class="src-str">'safe_mode'</span><span class="src-sym">)&nbsp;</span>&amp;&amp;&nbsp;<span class="src-sym">!</span><a href="http://www.php.net/ini_get">ini_get</a><span class="src-sym">(</span><span class="src-str">'open_basedir'</span><span class="src-sym">))&nbsp;</span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a284"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$options</span><span class="src-sym">[&nbsp;</span><span class="src-id">CURLOPT_FOLLOWLOCATION&nbsp;</span><span class="src-sym">]&nbsp;</span>=&nbsp;<span class="src-id">true</span><span class="src-sym">;&nbsp;&nbsp;</span><span class="src-comm">//&nbsp;follow&nbsp;redirects</span></div></li>
<li><div class="src-line"><a name="a285"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$options</span><span class="src-sym">[&nbsp;</span><span class="src-id">CURLOPT_AUTOREFERER&nbsp;</span><span class="src-sym">]&nbsp;&nbsp;&nbsp;&nbsp;</span>=&nbsp;<span class="src-id">true</span><span class="src-sym">;&nbsp;&nbsp;</span><span class="src-comm">//&nbsp;automatically&nbsp;set&nbsp;the&nbsp;Referer:&nbsp;field</span></div></li>
<li><div class="src-line"><a name="a286"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$options</span><span class="src-sym">[&nbsp;</span><span class="src-id">CURLOPT_MAXREDIRS&nbsp;</span><span class="src-sym">]&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>=&nbsp;<span class="src-num">5</span><span class="src-sym">;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="src-comm">//&nbsp;limit&nbsp;redirect&nbsp;loops</span></div></li>
<li><div class="src-line"><a name="a287"></a>&nbsp;&nbsp;&nbsp;&nbsp;</div></li>
<li><div class="src-line"><a name="a288"></a>&nbsp;&nbsp;<span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a289"></a>&nbsp;&nbsp;</div></li>
<li><div class="src-line"><a name="a290"></a>&nbsp;&nbsp;<span class="src-comm">//&nbsp;add&nbsp;custom&nbsp;cURL&nbsp;options&nbsp;(e.g.&nbsp;POST&nbsp;requests,&nbsp;cookies,&nbsp;etc.)</span></div></li>
<li><div class="src-line"><a name="a291"></a>&nbsp;&nbsp;<span class="src-key">if&nbsp;</span><span class="src-sym">(</span><a href="http://www.php.net/count">count</a><span class="src-sym">(</span><span class="src-var">$opts</span><span class="src-sym">)&nbsp;</span>&gt;&nbsp;<span class="src-num">0</span><span class="src-sym">)</span></div></li>
<li><div class="src-line"><a name="a292"></a>&nbsp;&nbsp;<span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a293"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-key">foreach&nbsp;</span><span class="src-sym">(</span><span class="src-var">$opts&nbsp;</span><span class="src-key">as&nbsp;</span><span class="src-var">$key&nbsp;</span>=&gt;&nbsp;<span class="src-var">$value</span><span class="src-sym">)&nbsp;</span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a294"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$options</span><span class="src-sym">[</span><span class="src-var">$key</span><span class="src-sym">]&nbsp;</span>=&nbsp;<span class="src-var">$value</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a295"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a296"></a>&nbsp;&nbsp;<span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a297"></a>&nbsp;&nbsp;</div></li>
<li><div class="src-line"><a name="a298"></a>&nbsp;&nbsp;<span class="src-var">$ch&nbsp;</span>=&nbsp;<a href="http://www.php.net/curl_init">curl_init</a><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a299"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a300"></a>&nbsp;&nbsp;<a href="http://www.php.net/curl_setopt_array">curl_setopt_array</a><span class="src-sym">(</span><span class="src-var">$ch</span><span class="src-sym">,&nbsp;</span><span class="src-var">$options</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a301"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a302"></a>&nbsp;&nbsp;<span class="src-var">$content&nbsp;&nbsp;</span>=&nbsp;<a href="http://www.php.net/curl_exec">curl_exec</a><span class="src-sym">(</span><span class="src-var">$ch</span><span class="src-sym">)</span><span class="src-sym">;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="src-comm">//&nbsp;the&nbsp;Web&nbsp;page</span></div></li>
<li><div class="src-line"><a name="a303"></a>&nbsp;&nbsp;<span class="src-var">$transfer&nbsp;</span>=&nbsp;<a href="http://www.php.net/curl_getinfo">curl_getinfo</a><span class="src-sym">(</span><span class="src-var">$ch</span><span class="src-sym">)</span><span class="src-sym">;&nbsp;&nbsp;</span><span class="src-comm">//&nbsp;transfer&nbsp;information&nbsp;(http://www.php.net/manual/en/function.curl-getinfo.php)</span></div></li>
<li><div class="src-line"><a name="a304"></a>&nbsp;&nbsp;<span class="src-var">$errnum&nbsp;&nbsp;&nbsp;</span>=&nbsp;<a href="http://www.php.net/curl_errno">curl_errno</a><span class="src-sym">(</span><span class="src-var">$ch</span><span class="src-sym">)</span><span class="src-sym">;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="src-comm">//&nbsp;codes:&nbsp;http://curl.haxx.se/libcurl/c/libcurl-errors.html</span></div></li>
<li><div class="src-line"><a name="a305"></a>&nbsp;&nbsp;<span class="src-var">$errmsg&nbsp;&nbsp;&nbsp;</span>=&nbsp;<a href="http://www.php.net/curl_error">curl_error</a><span class="src-sym">(</span><span class="src-var">$ch</span><span class="src-sym">)</span><span class="src-sym">;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="src-comm">//&nbsp;empty&nbsp;string&nbsp;on&nbsp;success</span></div></li>
<li><div class="src-line"><a name="a306"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a307"></a>&nbsp;&nbsp;<a href="http://www.php.net/curl_close">curl_close</a><span class="src-sym">(</span><span class="src-var">$ch</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a308"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a309"></a>&nbsp;&nbsp;<span class="src-comm">//&nbsp;extend&nbsp;transfer&nbsp;info</span></div></li>
<li><div class="src-line"><a name="a310"></a>&nbsp;&nbsp;<span class="src-var">$transfer</span><span class="src-sym">[</span><span class="src-str">'errnum'</span><span class="src-sym">]&nbsp;&nbsp;</span>=&nbsp;<span class="src-var">$errnum</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a311"></a>&nbsp;&nbsp;<span class="src-var">$transfer</span><span class="src-sym">[</span><span class="src-str">'errmsg'</span><span class="src-sym">]&nbsp;&nbsp;</span>=&nbsp;<span class="src-var">$errmsg</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a312"></a>&nbsp;&nbsp;<span class="src-var">$transfer</span><span class="src-sym">[</span><span class="src-str">'content'</span><span class="src-sym">]&nbsp;</span>=&nbsp;<span class="src-var">$content</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a313"></a>&nbsp;&nbsp;<span class="src-comm">//&nbsp;$transfer['url']&nbsp;is&nbsp;the&nbsp;final&nbsp;URL&nbsp;after&nbsp;redirections,&nbsp;if&nbsp;CURLOPT_FOLLOWLOCATION&nbsp;is&nbsp;set&nbsp;to&nbsp;true</span></div></li>
<li><div class="src-line"><a name="a314"></a>&nbsp;&nbsp;</div></li>
<li><div class="src-line"><a name="a315"></a>&nbsp;&nbsp;<span class="src-key">return&nbsp;</span><span class="src-var">$transfer</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a316"></a><span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a317"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a318"></a><span class="src-doc">/**&nbsp;</span></div></li>
<li><div class="src-line"><a name="a319"></a><span class="src-doc">&nbsp;*&nbsp;Displays&nbsp;a&nbsp;default&nbsp;error&nbsp;page.</span></div></li>
<li><div class="src-line"><a name="a320"></a><span class="src-doc">&nbsp;*&nbsp;Used&nbsp;when&nbsp;a&nbsp;cached&nbsp;page&nbsp;is&nbsp;deleted,&nbsp;as&nbsp;well&nbsp;as&nbsp;when&nbsp;cURL&nbsp;cannot&nbsp;fetch&nbsp;a&nbsp;remote&nbsp;page.</span></div></li>
<li><div class="src-line"><a name="a321"></a><span class="src-doc">&nbsp;*&nbsp;</span><span class="src-doc-coretag">@param&nbsp;</span><span class="src-doc">&nbsp;</span><span class="src-doc-type">string&nbsp;</span><span class="src-doc">&nbsp;&nbsp;</span><span class="src-doc-var">$bodyText&nbsp;</span><span class="src-doc">additional&nbsp;info&nbsp;to&nbsp;display&nbsp;on&nbsp;page&nbsp;body</span></div></li>
<li><div class="src-line"><a name="a322"></a><span class="src-doc">&nbsp;*&nbsp;</span><span class="src-doc-coretag">@return&nbsp;</span><span class="src-doc-type">string&nbsp;</span><span class="src-doc">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;The&nbsp;error&nbsp;page</span></div></li>
<li><div class="src-line"><a name="a323"></a><span class="src-doc">&nbsp;*/</span></div></li>
<li><div class="src-line"><a name="a324"></a><span class="src-key">function&nbsp;</span><a href="../smt2/_functions.php.html#functionerror_webpage">error_webpage</a><span class="src-sym">(</span><span class="src-var">$bodyText&nbsp;</span>=&nbsp;<span class="src-str">&quot;&quot;</span><span class="src-sym">)&nbsp;</span></div></li>
<li><div class="src-line"><a name="a325"></a><span class="src-sym">{&nbsp;&nbsp;</span></div></li>
<li><div class="src-line"><a name="a326"></a>&nbsp;&nbsp;<span class="src-var">$webpage&nbsp;</span>=&nbsp;<span class="src-str">'&lt;html&gt;&lt;head&gt;&lt;title&gt;Error&lt;/title&gt;&lt;/head&gt;&lt;body&gt;'</span>.<span class="src-var">$bodyText</span>.<span class="src-str">'&lt;/body&gt;&lt;/html&gt;'</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a327"></a>&nbsp;&nbsp;</div></li>
<li><div class="src-line"><a name="a328"></a>&nbsp;&nbsp;<span class="src-key">return&nbsp;</span><span class="src-var">$webpage</span><span class="src-sym">;&nbsp;</span></div></li>
<li><div class="src-line"><a name="a329"></a><span class="src-sym">}&nbsp;</span></div></li>
<li><div class="src-line"><a name="a330"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a331"></a><span class="src-doc">/**&nbsp;</span></div></li>
<li><div class="src-line"><a name="a332"></a><span class="src-doc">&nbsp;*&nbsp;Computes&nbsp;the&nbsp;frequency&nbsp;of&nbsp;each&nbsp;$input&nbsp;array&nbsp;member.</span></div></li>
<li><div class="src-line"><a name="a333"></a><span class="src-doc">&nbsp;*&nbsp;</span><span class="src-doc-coretag">@param&nbsp;</span><span class="src-doc">&nbsp;&nbsp;</span><span class="src-doc-type">mixed&nbsp;</span><span class="src-doc">&nbsp;</span><span class="src-doc-var">$input&nbsp;</span><span class="src-doc">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;input&nbsp;string&nbsp;or&nbsp;array&nbsp;of&nbsp;strings&nbsp;to&nbsp;parse&nbsp;($_POST&nbsp;vars&nbsp;are&nbsp;sent&nbsp;as&nbsp;strings)</span></div></li>
<li><div class="src-line"><a name="a334"></a><span class="src-doc">&nbsp;*&nbsp;</span><span class="src-doc-coretag">@param&nbsp;</span><span class="src-doc">&nbsp;&nbsp;</span><span class="src-doc-type">int&nbsp;</span><span class="src-doc">&nbsp;&nbsp;&nbsp;</span><span class="src-doc-var">$threshold&nbsp;</span><span class="src-doc">&nbsp;&nbsp;&nbsp;frequencies&nbsp;(in&nbsp;percentage)&nbsp;under&nbsp;this&nbsp;$threshold&nbsp;will&nbsp;not&nbsp;be&nbsp;stored&nbsp;(default:&nbsp;1)</span></div></li>
<li><div class="src-line"><a name="a335"></a><span class="src-doc">&nbsp;*&nbsp;</span><span class="src-doc-coretag">@return&nbsp;</span><span class="src-doc">&nbsp;</span><span class="src-doc-type">array&nbsp;</span><span class="src-doc">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;A&nbsp;sorted&nbsp;associative&nbsp;array&nbsp;in&nbsp;the&nbsp;form&nbsp;'[mostFrequentMember]=&gt;frequency,...,[lessFrequentMember]=&gt;frequency'</span></div></li>
<li><div class="src-line"><a name="a336"></a><span class="src-doc">&nbsp;*/</span></div></li>
<li><div class="src-line"><a name="a337"></a><span class="src-key">function&nbsp;</span><a href="../smt2/_functions.php.html#functioncompute_frequency">compute_frequency</a><span class="src-sym">(</span><span class="src-var">$input</span><span class="src-sym">,&nbsp;</span><span class="src-var">$threshold&nbsp;</span>=&nbsp;<span class="src-num">1</span><span class="src-sym">)&nbsp;</span></div></li>
<li><div class="src-line"><a name="a338"></a><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a339"></a>&nbsp;&nbsp;<span class="src-comm">//&nbsp;convert&nbsp;$input&nbsp;in&nbsp;a&nbsp;real&nbsp;PHP&nbsp;array</span></div></li>
<li><div class="src-line"><a name="a340"></a>&nbsp;&nbsp;<span class="src-var">$input&nbsp;</span>=&nbsp;<span class="src-sym">(</span><span class="src-sym">!</span><a href="http://www.php.net/is_array">is_array</a><span class="src-sym">(</span><span class="src-var">$input</span><span class="src-sym">))&nbsp;</span>?&nbsp;<a href="http://www.php.net/explode">explode</a><span class="src-sym">(</span><span class="src-str">&quot;,&quot;</span><span class="src-sym">,&nbsp;</span><span class="src-var">$input</span><span class="src-sym">)&nbsp;</span>:&nbsp;<span class="src-var">$input</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a341"></a>&nbsp;&nbsp;<span class="src-comm">//&nbsp;count&nbsp;occurrences&nbsp;(array&nbsp;keys&nbsp;must&nbsp;be&nbsp;strings&nbsp;or&nbsp;integers)</span></div></li>
<li><div class="src-line"><a name="a342"></a>&nbsp;&nbsp;<span class="src-var">$unique&nbsp;</span>=&nbsp;<a href="http://www.php.net/array_count_values">array_count_values</a><span class="src-sym">(</span><span class="src-var">$input</span><span class="src-sym">)</span><span class="src-sym">;&nbsp;</span><span class="src-comm">//&nbsp;Returns&nbsp;an&nbsp;associative&nbsp;array&nbsp;of&nbsp;values&nbsp;from&nbsp;$input&nbsp;as&nbsp;keys&nbsp;and&nbsp;their&nbsp;count&nbsp;as&nbsp;value.&nbsp;</span></div></li>
<li><div class="src-line"><a name="a343"></a>&nbsp;&nbsp;<span class="src-comm">//&nbsp;$hovered&nbsp;is&nbsp;an&nbsp;associative&nbsp;array(string&nbsp;=&gt;&nbsp;int)</span></div></li>
<li><div class="src-line"><a name="a344"></a>&nbsp;&nbsp;<span class="src-var">$unique&nbsp;</span>=&nbsp;<a href="../smt2/_functions.php.html#functionarray_sanitize">array_sanitize</a><span class="src-sym">(</span><span class="src-var">$unique</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a345"></a>&nbsp;&nbsp;</div></li>
<li><div class="src-line"><a name="a346"></a>&nbsp;&nbsp;<span class="src-comm">//&nbsp;exit&nbsp;if&nbsp;there&nbsp;are&nbsp;no&nbsp;data</span></div></li>
<li><div class="src-line"><a name="a347"></a>&nbsp;&nbsp;<span class="src-key">if&nbsp;</span><span class="src-sym">(</span><span class="src-sym">!</span><span class="src-var">$unique</span><span class="src-sym">)&nbsp;</span><span class="src-key">return&nbsp;</span><span class="src-id">false</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a348"></a>&nbsp;&nbsp;</div></li>
<li><div class="src-line"><a name="a349"></a>&nbsp;&nbsp;<span class="src-comm">//&nbsp;compute&nbsp;sum</span></div></li>
<li><div class="src-line"><a name="a350"></a>&nbsp;&nbsp;<span class="src-var">$sum&nbsp;&nbsp;</span>=&nbsp;<a href="http://www.php.net/array_sum">array_sum</a><span class="src-sym">(</span><span class="src-var">$unique</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a351"></a>&nbsp;&nbsp;<span class="src-var">$data&nbsp;</span>=&nbsp;<span class="src-key">array</span><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a352"></a>&nbsp;&nbsp;<span class="src-comm">//&nbsp;now&nbsp;calculate&nbsp;the&nbsp;frequency&nbsp;of&nbsp;each&nbsp;hovered&nbsp;element&nbsp;(in&nbsp;percentage)</span></div></li>
<li><div class="src-line"><a name="a353"></a>&nbsp;&nbsp;<span class="src-key">foreach&nbsp;</span><span class="src-sym">(</span><span class="src-var">$unique&nbsp;</span><span class="src-key">as&nbsp;</span><span class="src-var">$k&nbsp;</span>=&gt;&nbsp;<span class="src-var">$value</span><span class="src-sym">)&nbsp;</span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a354"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$frequency&nbsp;</span>=&nbsp;<a href="http://www.php.net/round">round</a><span class="src-sym">(</span><span class="src-num">100</span>*<span class="src-var">$value</span>/<span class="src-var">$sum</span><span class="src-sym">,&nbsp;</span><span class="src-num">2</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a355"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-comm">//&nbsp;store&nbsp;frecuencies&nbsp;above&nbsp;given&nbsp;threshold</span></div></li>
<li><div class="src-line"><a name="a356"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-key">if&nbsp;</span><span class="src-sym">(</span><span class="src-var">$frequency&nbsp;</span>&gt;&nbsp;<span class="src-var">$threshold</span><span class="src-sym">)&nbsp;</span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a357"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$data</span><span class="src-sym">[</span><span class="src-var">$k</span><span class="src-sym">]&nbsp;</span>=&nbsp;<span class="src-var">$frequency</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a358"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-sym">}&nbsp;</span></div></li>
<li><div class="src-line"><a name="a359"></a>&nbsp;&nbsp;<span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a360"></a>&nbsp;&nbsp;<span class="src-comm">//&nbsp;order&nbsp;by&nbsp;frecuency</span></div></li>
<li><div class="src-line"><a name="a361"></a>&nbsp;&nbsp;<a href="http://www.php.net/arsort">arsort</a><span class="src-sym">(</span><span class="src-var">$data</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a362"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a363"></a>&nbsp;&nbsp;<span class="src-key">return&nbsp;</span><span class="src-var">$data</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a364"></a><span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a365"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a366"></a><span class="src-doc">/**&nbsp;</span></div></li>
<li><div class="src-line"><a name="a367"></a><span class="src-doc">&nbsp;*&nbsp;Removes&nbsp;empty&nbsp;items&nbsp;(both&nbsp;key&nbsp;and&nbsp;value)&nbsp;from&nbsp;an&nbsp;associative&nbsp;numeric&nbsp;array.</span></div></li>
<li><div class="src-line"><a name="a368"></a><span class="src-doc">&nbsp;*&nbsp;</span><span class="src-doc-coretag">@param&nbsp;</span><span class="src-doc">&nbsp;&nbsp;</span><span class="src-doc-type">mixed&nbsp;</span><span class="src-doc">&nbsp;</span><span class="src-doc-var">$input&nbsp;</span><span class="src-doc">&nbsp;&nbsp;array&nbsp;or&nbsp;string&nbsp;to&nbsp;sanitize</span></div></li>
<li><div class="src-line"><a name="a369"></a><span class="src-doc">&nbsp;*&nbsp;</span><span class="src-doc-coretag">@return&nbsp;</span><span class="src-doc">&nbsp;</span><span class="src-doc-type">mixed&nbsp;</span><span class="src-doc">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Sanitized&nbsp;array&nbsp;or&nbsp;string&nbsp;(used&nbsp;for&nbsp;widget&nbsp;tracking)</span></div></li>
<li><div class="src-line"><a name="a370"></a><span class="src-doc">&nbsp;*/</span></div></li>
<li><div class="src-line"><a name="a371"></a><span class="src-key">function&nbsp;</span><a href="../smt2/_functions.php.html#functionarray_sanitize">array_sanitize</a><span class="src-sym">(</span><span class="src-var">$input</span><span class="src-sym">)</span></div></li>
<li><div class="src-line"><a name="a372"></a><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a373"></a>&nbsp;&nbsp;<span class="src-var">$isString&nbsp;</span>=&nbsp;<span class="src-id">false</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a374"></a>&nbsp;&nbsp;</div></li>
<li><div class="src-line"><a name="a375"></a>&nbsp;&nbsp;<span class="src-key">if&nbsp;</span><span class="src-sym">(</span><span class="src-sym">!</span><a href="http://www.php.net/is_array">is_array</a><span class="src-sym">(</span><span class="src-var">$input</span><span class="src-sym">))&nbsp;</span><span class="src-sym">{&nbsp;</span></div></li>
<li><div class="src-line"><a name="a376"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$input&nbsp;</span>=&nbsp;<a href="http://www.php.net/explode">explode</a><span class="src-sym">(</span><span class="src-str">&quot;,&quot;</span><span class="src-sym">,&nbsp;</span><span class="src-var">$input</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a377"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$isString&nbsp;</span>=&nbsp;<span class="src-id">true</span><span class="src-sym">;&nbsp;</span></div></li>
<li><div class="src-line"><a name="a378"></a>&nbsp;&nbsp;<span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a379"></a>&nbsp;&nbsp;</div></li>
<li><div class="src-line"><a name="a380"></a>&nbsp;&nbsp;<span class="src-var">$temp&nbsp;</span>=&nbsp;<span class="src-key">array</span><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">;&nbsp;&nbsp;</span></div></li>
<li><div class="src-line"><a name="a381"></a>&nbsp;&nbsp;<span class="src-key">foreach&nbsp;</span><span class="src-sym">(</span><span class="src-var">$input&nbsp;</span><span class="src-key">as&nbsp;</span><span class="src-var">$key&nbsp;</span>=&gt;&nbsp;<span class="src-var">$value</span><span class="src-sym">)&nbsp;</span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a382"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-comm">//&nbsp;avoid&nbsp;buggy&nbsp;values</span></div></li>
<li><div class="src-line"><a name="a383"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$key&nbsp;</span>=&nbsp;<a href="http://www.php.net/trim">trim</a><span class="src-sym">(</span><span class="src-var">$key</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a384"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$value&nbsp;</span>=&nbsp;<a href="http://www.php.net/trim">trim</a><span class="src-sym">(</span><span class="src-var">$value</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a385"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-comm">//&nbsp;store&nbsp;valid&nbsp;data</span></div></li>
<li><div class="src-line"><a name="a386"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-key">if&nbsp;</span><span class="src-sym">(</span><span class="src-sym">!</span><span class="src-key">empty</span><span class="src-sym">(</span><span class="src-var">$key</span><span class="src-sym">)&nbsp;</span>&amp;&amp;&nbsp;<span class="src-sym">!</span><span class="src-key">empty</span><span class="src-sym">(</span><span class="src-var">$value</span><span class="src-sym">))&nbsp;</span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a387"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$temp</span><span class="src-sym">[</span><span class="src-var">$key</span><span class="src-sym">]&nbsp;</span>=&nbsp;<span class="src-var">$value</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a388"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a389"></a>&nbsp;&nbsp;<span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a390"></a>&nbsp;&nbsp;</div></li>
<li><div class="src-line"><a name="a391"></a>&nbsp;&nbsp;<span class="src-key">return&nbsp;</span><span class="src-sym">(</span><span class="src-var">$isString</span><span class="src-sym">)&nbsp;</span>?&nbsp;<a href="http://www.php.net/implode">implode</a><span class="src-sym">(</span><span class="src-str">&quot;,&quot;</span><span class="src-sym">,&nbsp;</span><span class="src-var">$temp</span><span class="src-sym">)&nbsp;</span>:&nbsp;<span class="src-var">$temp</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a392"></a><span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a393"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a394"></a><span class="src-doc">/**&nbsp;</span></div></li>
<li><div class="src-line"><a name="a395"></a><span class="src-doc">&nbsp;*&nbsp;Convert&nbsp;null&nbsp;values&nbsp;to&nbsp;empty&nbsp;strings.&nbsp;Used&nbsp;to&nbsp;generate&nbsp;valid&nbsp;JSON&nbsp;arrays.</span></div></li>
<li><div class="src-line"><a name="a396"></a><span class="src-doc">&nbsp;*&nbsp;</span><span class="src-doc-coretag">@param&nbsp;</span><span class="src-doc">&nbsp;&nbsp;</span><span class="src-doc-type">array&nbsp;</span><span class="src-doc">&nbsp;</span><span class="src-doc-var">$input&nbsp;</span><span class="src-doc">&nbsp;&nbsp;array</span></div></li>
<li><div class="src-line"><a name="a397"></a><span class="src-doc">&nbsp;*&nbsp;</span><span class="src-doc-coretag">@return&nbsp;</span><span class="src-doc">&nbsp;</span><span class="src-doc-type">array&nbsp;</span><span class="src-doc">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Parsed&nbsp;array</span></div></li>
<li><div class="src-line"><a name="a398"></a><span class="src-doc">&nbsp;*/</span></div></li>
<li><div class="src-line"><a name="a399"></a><span class="src-key">function&nbsp;</span><a href="../smt2/_functions.php.html#functionarray_null">array_null</a><span class="src-sym">(</span><span class="src-var">$input</span><span class="src-sym">)</span></div></li>
<li><div class="src-line"><a name="a400"></a><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a401"></a>&nbsp;&nbsp;<span class="src-key">if&nbsp;</span><span class="src-sym">(</span><span class="src-sym">!</span><a href="http://www.php.net/is_array">is_array</a><span class="src-sym">(</span><span class="src-var">$input</span><span class="src-sym">))&nbsp;</span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a402"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$input&nbsp;</span>=&nbsp;<a href="http://www.php.net/explode">explode</a><span class="src-sym">(</span><span class="src-str">&quot;,&quot;</span><span class="src-sym">,&nbsp;</span><span class="src-var">$input</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a403"></a>&nbsp;&nbsp;<span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a404"></a>&nbsp;&nbsp;</div></li>
<li><div class="src-line"><a name="a405"></a>&nbsp;&nbsp;<span class="src-var">$temp&nbsp;</span>=&nbsp;<span class="src-key">array</span><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">;&nbsp;</span></div></li>
<li><div class="src-line"><a name="a406"></a>&nbsp;&nbsp;<span class="src-key">foreach&nbsp;</span><span class="src-sym">(</span><span class="src-var">$input&nbsp;</span><span class="src-key">as&nbsp;</span><span class="src-var">$key&nbsp;</span>=&gt;&nbsp;<span class="src-var">$value</span><span class="src-sym">)&nbsp;</span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a407"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-comm">//&nbsp;store&nbsp;valid&nbsp;data</span></div></li>
<li><div class="src-line"><a name="a408"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$temp</span><span class="src-sym">[</span><span class="src-var">$key</span><span class="src-sym">]&nbsp;</span>=&nbsp;<span class="src-sym">(</span><span class="src-sym">!</span><span class="src-key">empty</span><span class="src-sym">(</span><span class="src-var">$value</span><span class="src-sym">))&nbsp;</span>?&nbsp;<span class="src-var">$value&nbsp;</span>:&nbsp;<span class="src-num">0</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a409"></a>&nbsp;&nbsp;<span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a410"></a>&nbsp;&nbsp;</div></li>
<li><div class="src-line"><a name="a411"></a>&nbsp;&nbsp;<span class="src-key">return&nbsp;</span><span class="src-var">$temp</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a412"></a><span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a413"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a414"></a><span class="src-doc">/**&nbsp;</span></div></li>
<li><div class="src-line"><a name="a415"></a><span class="src-doc">&nbsp;*&nbsp;Does&nbsp;a&nbsp;weighted&nbsp;sum&nbsp;for&nbsp;a&nbsp;given&nbsp;multidimensional&nbsp;numeric&nbsp;array&nbsp;and&nbsp;computed&nbsp;weights.</span></div></li>
<li><div class="src-line"><a name="a416"></a><span class="src-doc">&nbsp;*&nbsp;</span><span class="src-doc-coretag">@param&nbsp;</span><span class="src-doc">&nbsp;&nbsp;</span><span class="src-doc-type">array&nbsp;</span><span class="src-doc">&nbsp;</span><span class="src-doc-var">$input&nbsp;</span><span class="src-doc">&nbsp;&nbsp;&nbsp;&nbsp;multidimensional&nbsp;array&nbsp;(matrix)</span></div></li>
<li><div class="src-line"><a name="a417"></a><span class="src-doc">&nbsp;*&nbsp;</span><span class="src-doc-coretag">@param&nbsp;</span><span class="src-doc">&nbsp;&nbsp;</span><span class="src-doc-type">array&nbsp;</span><span class="src-doc">&nbsp;</span><span class="src-doc-var">$weights&nbsp;</span><span class="src-doc">&nbsp;&nbsp;weights</span></div></li>
<li><div class="src-line"><a name="a418"></a><span class="src-doc">&nbsp;*&nbsp;</span><span class="src-doc-coretag">@return&nbsp;</span><span class="src-doc">&nbsp;</span><span class="src-doc-type">array&nbsp;</span><span class="src-doc">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Weighted&nbsp;sum</span></div></li>
<li><div class="src-line"><a name="a419"></a><span class="src-doc">&nbsp;*&nbsp;</span><span class="src-doc-coretag">@link</span><span class="src-doc">&nbsp;&nbsp;&nbsp;&nbsp;http://www.compapp.dcu.ie/~humphrys/PhD/e.html</span></div></li>
<li><div class="src-line"><a name="a420"></a><span class="src-doc">&nbsp;*/</span></div></li>
<li><div class="src-line"><a name="a421"></a><span class="src-key">function&nbsp;</span><a href="../smt2/_functions.php.html#functionweighted_avg">weighted_avg</a><span class="src-sym">(</span><span class="src-var">$input</span><span class="src-sym">,&nbsp;</span><span class="src-var">$weights</span><span class="src-sym">)&nbsp;</span></div></li>
<li><div class="src-line"><a name="a422"></a><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a423"></a>&nbsp;&nbsp;<span class="src-var">$sumArray&nbsp;</span>=&nbsp;<span class="src-key">array</span><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a424"></a>&nbsp;&nbsp;</div></li>
<li><div class="src-line"><a name="a425"></a>&nbsp;&nbsp;<span class="src-key">foreach&nbsp;</span><span class="src-sym">(</span><span class="src-var">$input&nbsp;</span><span class="src-key">as&nbsp;</span><span class="src-var">$arrItem</span><span class="src-sym">)&nbsp;</span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a426"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$sumArray</span><span class="src-sym">[</span><span class="src-sym">]&nbsp;</span>=&nbsp;<a href="../smt2/_functions.php.html#functionarray_avg">array_avg</a><span class="src-sym">(</span><span class="src-var">$arrItem</span><span class="src-sym">)&nbsp;</span>*&nbsp;<a href="http://www.php.net/count">count</a><span class="src-sym">(</span><span class="src-var">$arrItem</span><span class="src-sym">)&nbsp;</span>/&nbsp;<a href="http://www.php.net/max">max</a><span class="src-sym">(</span><span class="src-var">$weights</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a427"></a>&nbsp;&nbsp;<span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a428"></a>&nbsp;&nbsp;</div></li>
<li><div class="src-line"><a name="a429"></a>&nbsp;&nbsp;<span class="src-key">return&nbsp;</span><span class="src-var">$sumArray</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a430"></a><span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a431"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a432"></a><span class="src-doc">/**&nbsp;</span></div></li>
<li><div class="src-line"><a name="a433"></a><span class="src-doc">&nbsp;*&nbsp;Computes&nbsp;the&nbsp;average&nbsp;sum&nbsp;of&nbsp;a&nbsp;numeric&nbsp;array.</span></div></li>
<li><div class="src-line"><a name="a434"></a><span class="src-doc">&nbsp;*&nbsp;</span><span class="src-doc-coretag">@param&nbsp;</span><span class="src-doc">&nbsp;&nbsp;</span><span class="src-doc-type">array&nbsp;</span><span class="src-doc">&nbsp;</span><span class="src-doc-var">$input&nbsp;</span><span class="src-doc">&nbsp;&nbsp;array&nbsp;or&nbsp;set&nbsp;of&nbsp;arrays&nbsp;(matrix)</span></div></li>
<li><div class="src-line"><a name="a435"></a><span class="src-doc">&nbsp;*&nbsp;</span><span class="src-doc-coretag">@return&nbsp;</span><span class="src-doc">&nbsp;</span><span class="src-doc-type">float&nbsp;</span><span class="src-doc">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Array&nbsp;average</span></div></li>
<li><div class="src-line"><a name="a436"></a><span class="src-doc">&nbsp;*/</span></div></li>
<li><div class="src-line"><a name="a437"></a><span class="src-key">function&nbsp;</span><a href="../smt2/_functions.php.html#functionarray_avg">array_avg</a><span class="src-sym">(</span><span class="src-var">$input</span><span class="src-sym">)</span></div></li>
<li><div class="src-line"><a name="a438"></a><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a439"></a>&nbsp;&nbsp;<span class="src-key">return&nbsp;</span><a href="http://www.php.net/round">round</a><span class="src-sym">(&nbsp;</span><a href="http://www.php.net/array_sum">array_sum</a><span class="src-sym">(</span><span class="src-var">$input</span><span class="src-sym">)&nbsp;</span>/&nbsp;<a href="http://www.php.net/count">count</a><span class="src-sym">(</span><span class="src-var">$input</span><span class="src-sym">)</span><span class="src-sym">,&nbsp;</span><span class="src-num">2</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a440"></a><span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a441"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a442"></a><span class="src-doc">/**</span></div></li>
<li><div class="src-line"><a name="a443"></a><span class="src-doc">&nbsp;*&nbsp;Computes&nbsp;the&nbsp;average&nbsp;sum&nbsp;of&nbsp;a&nbsp;matrix,&nbsp;assuming&nbsp;that&nbsp;each&nbsp;row&nbsp;is&nbsp;a&nbsp;numeric&nbsp;array.</span></div></li>
<li><div class="src-line"><a name="a444"></a><span class="src-doc">&nbsp;*&nbsp;</span><span class="src-doc-coretag">@param&nbsp;</span><span class="src-doc">&nbsp;&nbsp;</span><span class="src-doc-type">array&nbsp;</span><span class="src-doc-var">$matrix&nbsp;</span><span class="src-doc">a&nbsp;set&nbsp;of&nbsp;arrays&nbsp;(matrix)</span></div></li>
<li><div class="src-line"><a name="a445"></a><span class="src-doc">&nbsp;*&nbsp;</span><span class="src-doc-coretag">@return&nbsp;</span><span class="src-doc">&nbsp;</span><span class="src-doc-type">float&nbsp;</span><span class="src-doc">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;matrix&nbsp;average&nbsp;value</span></div></li>
<li><div class="src-line"><a name="a446"></a><span class="src-doc">&nbsp;*/</span></div></li>
<li><div class="src-line"><a name="a447"></a><span class="src-key">function&nbsp;</span><a href="../smt2/_functions.php.html#functionmatrix_avg">matrix_avg</a><span class="src-sym">(</span><span class="src-var">$matrix</span><span class="src-sym">)</span></div></li>
<li><div class="src-line"><a name="a448"></a><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a449"></a>&nbsp;&nbsp;<span class="src-var">$sum&nbsp;</span>=&nbsp;<span class="src-num">0</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a450"></a>&nbsp;&nbsp;<span class="src-var">$count&nbsp;</span>=&nbsp;<span class="src-num">0</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a451"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a452"></a>&nbsp;&nbsp;<span class="src-key">foreach&nbsp;</span><span class="src-sym">(</span><span class="src-var">$matrix&nbsp;</span><span class="src-key">as&nbsp;</span><span class="src-var">$arrItem</span><span class="src-sym">)</span></div></li>
<li><div class="src-line"><a name="a453"></a>&nbsp;&nbsp;<span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a454"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-key">if&nbsp;</span><span class="src-sym">(</span><span class="src-sym">!</span><a href="http://www.php.net/is_array">is_array</a><span class="src-sym">(</span><span class="src-var">$arrItem</span><span class="src-sym">))&nbsp;</span><span class="src-sym">{&nbsp;</span><span class="src-var">$arrItem&nbsp;</span>=&nbsp;<a href="http://www.php.net/explode">explode</a><span class="src-sym">(</span><span class="src-str">&quot;,&quot;</span><span class="src-sym">,&nbsp;</span><span class="src-var">$arrItem</span><span class="src-sym">)</span><span class="src-sym">;&nbsp;</span><span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a455"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a456"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$sum&nbsp;</span>+=&nbsp;<a href="../smt2/_functions.php.html#functionarray_avg">array_avg</a><span class="src-sym">(</span><span class="src-var">$arrItem</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a457"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-comm">//&nbsp;note&nbsp;that&nbsp;this&nbsp;is&nbsp;an&nbsp;accumulative&nbsp;sum</span></div></li>
<li><div class="src-line"><a name="a458"></a>&nbsp;&nbsp;&nbsp;&nbsp;++<span class="src-var">$count</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a459"></a>&nbsp;&nbsp;<span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a460"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a461"></a>&nbsp;&nbsp;<span class="src-key">return&nbsp;</span><a href="http://www.php.net/round">round</a><span class="src-sym">(&nbsp;</span><span class="src-var">$sum</span>/<span class="src-var">$count</span><span class="src-sym">,&nbsp;</span><span class="src-num">2&nbsp;</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a462"></a><span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a463"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a464"></a><span class="src-doc">/**</span></div></li>
<li><div class="src-line"><a name="a465"></a><span class="src-doc">&nbsp;*&nbsp;Computes&nbsp;the&nbsp;variance&nbsp;of&nbsp;a&nbsp;numeric&nbsp;array.</span></div></li>
<li><div class="src-line"><a name="a466"></a><span class="src-doc">&nbsp;*&nbsp;</span><span class="src-doc-coretag">@param&nbsp;</span><span class="src-doc">&nbsp;&nbsp;</span><span class="src-doc-type">array&nbsp;</span><span class="src-doc">&nbsp;</span><span class="src-doc-var">$input&nbsp;</span><span class="src-doc">&nbsp;&nbsp;array</span></div></li>
<li><div class="src-line"><a name="a467"></a><span class="src-doc">&nbsp;*&nbsp;</span><span class="src-doc-coretag">@return&nbsp;</span><span class="src-doc">&nbsp;</span><span class="src-doc-type">int&nbsp;</span><span class="src-doc">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Array&nbsp;index</span></div></li>
<li><div class="src-line"><a name="a468"></a><span class="src-doc">&nbsp;*/</span></div></li>
<li><div class="src-line"><a name="a469"></a><span class="src-key">function&nbsp;</span><a href="../smt2/_functions.php.html#functionarray_sd">array_sd</a><span class="src-sym">(</span><span class="src-var">$input</span><span class="src-sym">)</span></div></li>
<li><div class="src-line"><a name="a470"></a><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a471"></a>&nbsp;&nbsp;<span class="src-var">$variance&nbsp;</span>=&nbsp;<span class="src-num">0</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a472"></a>&nbsp;&nbsp;<span class="src-var">$mean&nbsp;</span>=&nbsp;<a href="../smt2/_functions.php.html#functionarray_avg">array_avg</a><span class="src-sym">(</span><span class="src-var">$input</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a473"></a>&nbsp;&nbsp;<span class="src-key">foreach&nbsp;</span><span class="src-sym">(</span><span class="src-var">$input&nbsp;</span><span class="src-key">as&nbsp;</span><span class="src-var">$elem</span><span class="src-sym">)&nbsp;</span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a474"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$variance&nbsp;</span>+=&nbsp;<span class="src-sym">(</span><span class="src-var">$elem&nbsp;</span>-&nbsp;<span class="src-var">$mean</span><span class="src-sym">)&nbsp;</span>*&nbsp;<span class="src-sym">(</span><span class="src-var">$elem&nbsp;</span>-&nbsp;<span class="src-var">$mean</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a475"></a>&nbsp;&nbsp;<span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a476"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a477"></a>&nbsp;&nbsp;<span class="src-key">return&nbsp;</span><a href="http://www.php.net/round">round</a><span class="src-sym">(&nbsp;</span><a href="http://www.php.net/sqrt">sqrt</a><span class="src-sym">(</span><span class="src-var">$variance</span>/<a href="http://www.php.net/count">count</a><span class="src-sym">(</span><span class="src-var">$input</span><span class="src-sym">))</span><span class="src-sym">,&nbsp;</span><span class="src-num">2&nbsp;</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a478"></a><span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a479"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a480"></a><span class="src-doc">/**</span></div></li>
<li><div class="src-line"><a name="a481"></a><span class="src-doc">&nbsp;*&nbsp;Computes&nbsp;the&nbsp;standard&nbsp;deviation&nbsp;of&nbsp;a&nbsp;matrix,&nbsp;assuming&nbsp;that&nbsp;each&nbsp;row&nbsp;is&nbsp;a&nbsp;numeric&nbsp;array.</span></div></li>
<li><div class="src-line"><a name="a482"></a><span class="src-doc">&nbsp;*&nbsp;</span><span class="src-doc-coretag">@param&nbsp;</span><span class="src-doc">&nbsp;&nbsp;</span><span class="src-doc-type">array&nbsp;</span><span class="src-doc-var">$matrix&nbsp;</span><span class="src-doc">a&nbsp;set&nbsp;of&nbsp;arrays&nbsp;(matrix)</span></div></li>
<li><div class="src-line"><a name="a483"></a><span class="src-doc">&nbsp;*&nbsp;</span><span class="src-doc-coretag">@return&nbsp;</span><span class="src-doc">&nbsp;</span><span class="src-doc-type">float&nbsp;</span><span class="src-doc">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;matrix&nbsp;average&nbsp;value</span></div></li>
<li><div class="src-line"><a name="a484"></a><span class="src-doc">&nbsp;*/</span></div></li>
<li><div class="src-line"><a name="a485"></a><span class="src-key">function&nbsp;</span><a href="../smt2/_functions.php.html#functionmatrix_sd">matrix_sd</a><span class="src-sym">(</span><span class="src-var">$matrix</span><span class="src-sym">)</span></div></li>
<li><div class="src-line"><a name="a486"></a><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a487"></a>&nbsp;&nbsp;<span class="src-var">$sd&nbsp;</span>=&nbsp;<span class="src-num">0</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a488"></a>&nbsp;&nbsp;<span class="src-var">$count&nbsp;</span>=&nbsp;<span class="src-num">0</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a489"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a490"></a>&nbsp;&nbsp;<span class="src-key">foreach&nbsp;</span><span class="src-sym">(</span><span class="src-var">$matrix&nbsp;</span><span class="src-key">as&nbsp;</span><span class="src-var">$arrItem</span><span class="src-sym">)</span></div></li>
<li><div class="src-line"><a name="a491"></a>&nbsp;&nbsp;<span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a492"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-key">if&nbsp;</span><span class="src-sym">(</span><span class="src-sym">!</span><a href="http://www.php.net/is_array">is_array</a><span class="src-sym">(</span><span class="src-var">$arrItem</span><span class="src-sym">))&nbsp;</span><span class="src-sym">{&nbsp;</span><span class="src-var">$arrItem&nbsp;</span>=&nbsp;<a href="http://www.php.net/explode">explode</a><span class="src-sym">(</span><span class="src-str">&quot;,&quot;</span><span class="src-sym">,&nbsp;</span><span class="src-var">$arrItem</span><span class="src-sym">)</span><span class="src-sym">;&nbsp;</span><span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a493"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a494"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$sd&nbsp;</span>+=&nbsp;<a href="../smt2/_functions.php.html#functionarray_sd">array_sd</a><span class="src-sym">(</span><span class="src-var">$arrItem</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a495"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a496"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-comm">//&nbsp;note&nbsp;that&nbsp;we&nbsp;can&nbsp;have&nbsp;more&nbsp;than&nbsp;one&nbsp;input&nbsp;array</span></div></li>
<li><div class="src-line"><a name="a497"></a>&nbsp;&nbsp;&nbsp;&nbsp;++<span class="src-var">$count</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a498"></a>&nbsp;&nbsp;<span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a499"></a>&nbsp;&nbsp;</div></li>
<li><div class="src-line"><a name="a500"></a>&nbsp;&nbsp;<span class="src-key">return&nbsp;</span><a href="http://www.php.net/round">round</a><span class="src-sym">(&nbsp;</span><span class="src-var">$sd</span>/<span class="src-var">$count</span><span class="src-sym">,&nbsp;</span><span class="src-num">2&nbsp;</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a501"></a><span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a502"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a503"></a><span class="src-doc">/**&nbsp;</span></div></li>
<li><div class="src-line"><a name="a504"></a><span class="src-doc">&nbsp;*&nbsp;Gets&nbsp;the&nbsp;array&nbsp;index&nbsp;that&nbsp;has&nbsp;the&nbsp;maximum&nbsp;value.</span></div></li>
<li><div class="src-line"><a name="a505"></a><span class="src-doc">&nbsp;*&nbsp;</span><span class="src-doc-coretag">@param&nbsp;</span><span class="src-doc">&nbsp;&nbsp;</span><span class="src-doc-type">array&nbsp;</span><span class="src-doc">&nbsp;</span><span class="src-doc-var">$input&nbsp;</span><span class="src-doc">&nbsp;&nbsp;array</span></div></li>
<li><div class="src-line"><a name="a506"></a><span class="src-doc">&nbsp;*&nbsp;</span><span class="src-doc-coretag">@return&nbsp;</span><span class="src-doc">&nbsp;</span><span class="src-doc-type">int&nbsp;</span><span class="src-doc">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Array&nbsp;index</span></div></li>
<li><div class="src-line"><a name="a507"></a><span class="src-doc">&nbsp;*/</span></div></li>
<li><div class="src-line"><a name="a508"></a><span class="src-key">function&nbsp;</span><a href="../smt2/_functions.php.html#functionarray_argmax">array_argmax</a><span class="src-sym">(</span><span class="src-var">$input</span><span class="src-sym">)</span></div></li>
<li><div class="src-line"><a name="a509"></a><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a510"></a>&nbsp;&nbsp;<span class="src-var">$max&nbsp;</span>=&nbsp;<a href="http://www.php.net/max">max</a><span class="src-sym">(</span><span class="src-var">$input</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a511"></a>&nbsp;&nbsp;<span class="src-key">foreach&nbsp;</span><span class="src-sym">(</span><span class="src-var">$input&nbsp;</span><span class="src-key">as&nbsp;</span><span class="src-var">$key&nbsp;</span>=&gt;&nbsp;<span class="src-var">$value</span><span class="src-sym">)</span></div></li>
<li><div class="src-line"><a name="a512"></a>&nbsp;&nbsp;<span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a513"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-key">if&nbsp;</span><span class="src-sym">(</span><span class="src-var">$value&nbsp;</span>==&nbsp;<span class="src-var">$max</span><span class="src-sym">)&nbsp;</span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a514"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$maxIndex&nbsp;</span>=&nbsp;<span class="src-var">$key</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a515"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-key">break</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a516"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a517"></a>&nbsp;&nbsp;<span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a518"></a>&nbsp;&nbsp;</div></li>
<li><div class="src-line"><a name="a519"></a>&nbsp;&nbsp;<span class="src-key">return&nbsp;</span><span class="src-var">$maxIndex</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a520"></a><span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a521"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a522"></a><span class="src-doc">/**&nbsp;</span></div></li>
<li><div class="src-line"><a name="a523"></a><span class="src-doc">&nbsp;*&nbsp;Gets&nbsp;the&nbsp;array&nbsp;index&nbsp;that&nbsp;has&nbsp;the&nbsp;minimum&nbsp;value.</span></div></li>
<li><div class="src-line"><a name="a524"></a><span class="src-doc">&nbsp;*&nbsp;</span><span class="src-doc-coretag">@param&nbsp;</span><span class="src-doc">&nbsp;&nbsp;</span><span class="src-doc-type">array&nbsp;</span><span class="src-doc">&nbsp;</span><span class="src-doc-var">$input&nbsp;</span><span class="src-doc">&nbsp;&nbsp;array</span></div></li>
<li><div class="src-line"><a name="a525"></a><span class="src-doc">&nbsp;*&nbsp;</span><span class="src-doc-coretag">@return&nbsp;</span><span class="src-doc">&nbsp;</span><span class="src-doc-type">int&nbsp;</span><span class="src-doc">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Array&nbsp;index</span></div></li>
<li><div class="src-line"><a name="a526"></a><span class="src-doc">&nbsp;*/</span></div></li>
<li><div class="src-line"><a name="a527"></a><span class="src-key">function&nbsp;</span><a href="../smt2/_functions.php.html#functionarray_argmin">array_argmin</a><span class="src-sym">(</span><span class="src-var">$input</span><span class="src-sym">)</span></div></li>
<li><div class="src-line"><a name="a528"></a><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a529"></a>&nbsp;&nbsp;<span class="src-var">$min&nbsp;</span>=&nbsp;<a href="http://www.php.net/min">min</a><span class="src-sym">(</span><span class="src-var">$input</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a530"></a>&nbsp;&nbsp;<span class="src-key">foreach&nbsp;</span><span class="src-sym">(</span><span class="src-var">$input&nbsp;</span><span class="src-key">as&nbsp;</span><span class="src-var">$key&nbsp;</span>=&gt;&nbsp;<span class="src-var">$value</span><span class="src-sym">)</span></div></li>
<li><div class="src-line"><a name="a531"></a>&nbsp;&nbsp;<span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a532"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-key">if&nbsp;</span><span class="src-sym">(</span><span class="src-var">$value&nbsp;</span>==&nbsp;<span class="src-var">$min</span><span class="src-sym">)&nbsp;</span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a533"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$minIndex&nbsp;</span>=&nbsp;<span class="src-var">$key</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a534"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-key">break</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a535"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a536"></a>&nbsp;&nbsp;<span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a537"></a>&nbsp;&nbsp;</div></li>
<li><div class="src-line"><a name="a538"></a>&nbsp;&nbsp;<span class="src-key">return&nbsp;</span><span class="src-var">$minIndex</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a539"></a><span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a540"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a541"></a><span class="src-doc">/**</span></div></li>
<li><div class="src-line"><a name="a542"></a><span class="src-doc">&nbsp;*&nbsp;Denests&nbsp;nested&nbsp;arrays&nbsp;within&nbsp;the&nbsp;given&nbsp;array.</span></div></li>
<li><div class="src-line"><a name="a543"></a><span class="src-doc">&nbsp;*&nbsp;</span><span class="src-doc-tag">@autor</span><span class="src-doc">&nbsp;DZone&nbsp;Snippets</span></div></li>
<li><div class="src-line"><a name="a544"></a><span class="src-doc">&nbsp;*&nbsp;</span><span class="src-doc-coretag">@link</span><span class="src-doc">&nbsp;&nbsp;http://snippets.dzone.com/posts/show/4660</span></div></li>
<li><div class="src-line"><a name="a545"></a><span class="src-doc">&nbsp;*/</span></div></li>
<li><div class="src-line"><a name="a546"></a><span class="src-key">function&nbsp;</span><a href="../smt2/_functions.php.html#functionarray_flatten">array_flatten</a><span class="src-sym">(</span><span class="src-var">$input</span><span class="src-sym">)</span></div></li>
<li><div class="src-line"><a name="a547"></a><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a548"></a>&nbsp;&nbsp;<span class="src-var">$i&nbsp;</span>=&nbsp;<span class="src-num">0</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a549"></a>&nbsp;&nbsp;<span class="src-key">while&nbsp;</span><span class="src-sym">(</span><span class="src-var">$i&nbsp;</span>&lt;&nbsp;<a href="http://www.php.net/count">count</a><span class="src-sym">(</span><span class="src-var">$input</span><span class="src-sym">))</span></div></li>
<li><div class="src-line"><a name="a550"></a>&nbsp;&nbsp;<span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a551"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-key">if&nbsp;</span><span class="src-sym">(</span><a href="http://www.php.net/is_array">is_array</a><span class="src-sym">(</span><span class="src-var">$input</span><span class="src-sym">[</span><span class="src-var">$i</span><span class="src-sym">]</span><span class="src-sym">))&nbsp;</span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a552"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="http://www.php.net/array_splice">array_splice</a><span class="src-sym">(</span><span class="src-var">$input</span><span class="src-sym">,&nbsp;</span><span class="src-var">$i</span><span class="src-sym">,&nbsp;</span><span class="src-num">1</span><span class="src-sym">,&nbsp;</span><span class="src-var">$input</span><span class="src-sym">[</span><span class="src-var">$i</span><span class="src-sym">]</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a553"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-sym">}&nbsp;</span><span class="src-key">else&nbsp;</span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a554"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;++<span class="src-var">$i</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a555"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a556"></a>&nbsp;&nbsp;<span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a557"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a558"></a>&nbsp;&nbsp;<span class="src-key">return&nbsp;</span><span class="src-var">$input</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a559"></a><span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a560"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a561"></a><span class="src-doc">/**&nbsp;</span></div></li>
<li><div class="src-line"><a name="a562"></a><span class="src-doc">&nbsp;*&nbsp;Merges&nbsp;vertical&nbsp;and&nbsp;horizontal&nbsp;coordinates&nbsp;in&nbsp;a&nbsp;bidimensional&nbsp;point&nbsp;array.</span></div></li>
<li><div class="src-line"><a name="a563"></a><span class="src-doc">&nbsp;*&nbsp;Stops&nbsp;coordinates&nbsp;(hesitations)&nbsp;are&nbsp;removed.</span></div></li>
<li><div class="src-line"><a name="a564"></a><span class="src-doc">&nbsp;*&nbsp;</span><span class="src-doc-coretag">@param&nbsp;</span><span class="src-doc">&nbsp;&nbsp;</span><span class="src-doc-type">array&nbsp;</span><span class="src-doc">&nbsp;</span><span class="src-doc-var">$xcoords&nbsp;</span><span class="src-doc">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;horizontal&nbsp;coordinates</span></div></li>
<li><div class="src-line"><a name="a565"></a><span class="src-doc">&nbsp;*&nbsp;</span><span class="src-doc-coretag">@param&nbsp;</span><span class="src-doc">&nbsp;&nbsp;</span><span class="src-doc-type">array&nbsp;</span><span class="src-doc">&nbsp;</span><span class="src-doc-var">$ycoords&nbsp;</span><span class="src-doc">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;vertical&nbsp;coordinates</span></div></li>
<li><div class="src-line"><a name="a566"></a><span class="src-doc">&nbsp;*&nbsp;</span><span class="src-doc-coretag">@param&nbsp;</span><span class="src-doc">&nbsp;&nbsp;</span><span class="src-doc-type">array&nbsp;</span><span class="src-doc">&nbsp;</span><span class="src-doc-var">$getDistances&nbsp;</span><span class="src-doc">&nbsp;&nbsp;if&nbsp;TRUE,&nbsp;the&nbsp;result&nbsp;array&nbsp;contains&nbsp;euclidean&nbsp;distances</span></div></li>
<li><div class="src-line"><a name="a567"></a><span class="src-doc">&nbsp;*&nbsp;</span><span class="src-doc-coretag">@return&nbsp;</span><span class="src-doc">&nbsp;</span><span class="src-doc-type">array&nbsp;</span><span class="src-doc">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;2D&nbsp;points&nbsp;or&nbsp;euclidean&nbsp;distances&nbsp;array</span></div></li>
<li><div class="src-line"><a name="a568"></a><span class="src-doc">&nbsp;*/</span></div></li>
<li><div class="src-line"><a name="a569"></a><span class="src-key">function&nbsp;</span><a href="../smt2/_functions.php.html#functionconvert_points">convert_points</a><span class="src-sym">(</span><span class="src-var">$xcoords</span><span class="src-sym">,&nbsp;</span><span class="src-var">$ycoords</span><span class="src-sym">,&nbsp;</span><span class="src-var">$getDistances&nbsp;</span>=&nbsp;<span class="src-id">false</span><span class="src-sym">)&nbsp;</span></div></li>
<li><div class="src-line"><a name="a570"></a><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a571"></a>&nbsp;&nbsp;<span class="src-comm">//&nbsp;initialize&nbsp;points&nbsp;array</span></div></li>
<li><div class="src-line"><a name="a572"></a>&nbsp;&nbsp;<span class="src-var">$pointArray&nbsp;</span>=&nbsp;<span class="src-key">array</span><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a573"></a>&nbsp;&nbsp;<span class="src-comm">//&nbsp;check&nbsp;for&nbsp;illegal&nbsp;offsets&nbsp;on&nbsp;$coords</span></div></li>
<li><div class="src-line"><a name="a574"></a>&nbsp;&nbsp;<span class="src-var">$maxCount&nbsp;</span>=&nbsp;<a href="http://www.php.net/count">count</a><span class="src-sym">(</span><span class="src-var">$xcoords</span><span class="src-sym">)&nbsp;</span>-&nbsp;<span class="src-num">1</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a575"></a>&nbsp;&nbsp;<span class="src-comm">//&nbsp;transform&nbsp;arrays&nbsp;in&nbsp;a&nbsp;single&nbsp;points&nbsp;array</span></div></li>
<li><div class="src-line"><a name="a576"></a>&nbsp;&nbsp;<span class="src-key">foreach&nbsp;</span><span class="src-sym">(</span><span class="src-var">$xcoords&nbsp;</span><span class="src-key">as&nbsp;</span><span class="src-var">$i&nbsp;</span>=&gt;&nbsp;<span class="src-var">$value</span><span class="src-sym">)&nbsp;</span></div></li>
<li><div class="src-line"><a name="a577"></a>&nbsp;&nbsp;<span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a578"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$p&nbsp;</span>=&nbsp;<span class="src-key">new&nbsp;</span><span class="src-id"><a href="../smt2/Point.html">Point</a></span><span class="src-sym">(</span><span class="src-var">$value</span><span class="src-sym">,&nbsp;</span><span class="src-var">$ycoords</span><span class="src-sym">[</span><span class="src-var">$i</span><span class="src-sym">]</span><span class="src-sym">)</span><span class="src-sym">;&nbsp;</span></div></li>
<li><div class="src-line"><a name="a579"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-comm">//&nbsp;check&nbsp;if&nbsp;next&nbsp;point&nbsp;exists&nbsp;</span></div></li>
<li><div class="src-line"><a name="a580"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-key">if&nbsp;</span><span class="src-sym">(</span><span class="src-var">$i&nbsp;</span>&gt;=&nbsp;<span class="src-var">$maxCount</span><span class="src-sym">)&nbsp;</span><span class="src-sym">{&nbsp;</span><span class="src-key">break</span><span class="src-sym">;&nbsp;</span><span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a581"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-comm">//&nbsp;ok</span></div></li>
<li><div class="src-line"><a name="a582"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$q&nbsp;</span>=&nbsp;<span class="src-key">new&nbsp;</span><span class="src-id"><a href="../smt2/Point.html">Point</a></span><span class="src-sym">(</span><span class="src-var">$xcoords</span><span class="src-sym">[</span><span class="src-var">$i&nbsp;</span>+&nbsp;<span class="src-num">1</span><span class="src-sym">]</span><span class="src-sym">,&nbsp;</span><span class="src-var">$ycoords</span><span class="src-sym">[</span><span class="src-var">$i&nbsp;</span>+&nbsp;<span class="src-num">1</span><span class="src-sym">]</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a583"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$distance&nbsp;</span>=&nbsp;<span class="src-var">$p</span><span class="src-sym">-&gt;</span><span class="src-id">getDistance</span><span class="src-sym">(</span><span class="src-var">$q</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a584"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-comm">//&nbsp;check</span></div></li>
<li><div class="src-line"><a name="a585"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-key">if&nbsp;</span><span class="src-sym">(</span><span class="src-var">$getDistances</span><span class="src-sym">)&nbsp;</span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a586"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$pointArray</span><span class="src-sym">[</span><span class="src-sym">]&nbsp;</span>=&nbsp;<span class="src-var">$distance</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a587"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-sym">}&nbsp;</span><span class="src-key">else&nbsp;</span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a588"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-comm">//&nbsp;append&nbsp;point&nbsp;to&nbsp;the&nbsp;points&nbsp;array,&nbsp;discarding&nbsp;null&nbsp;distances</span></div></li>
<li><div class="src-line"><a name="a589"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-key">if&nbsp;</span><span class="src-sym">(</span><span class="src-var">$distance&nbsp;</span>&gt;&nbsp;<span class="src-num">0</span><span class="src-sym">)&nbsp;</span><span class="src-sym">{&nbsp;</span><span class="src-var">$pointArray</span><span class="src-sym">[</span><span class="src-sym">]&nbsp;</span>=&nbsp;<span class="src-var">$p</span><span class="src-sym">;&nbsp;</span><span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a590"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a591"></a>&nbsp;&nbsp;<span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a592"></a>&nbsp;&nbsp;</div></li>
<li><div class="src-line"><a name="a593"></a>&nbsp;&nbsp;<span class="src-key">return&nbsp;</span><span class="src-var">$pointArray</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a594"></a><span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a595"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a596"></a><span class="src-doc">/**</span></div></li>
<li><div class="src-line"><a name="a597"></a><span class="src-doc">&nbsp;*&nbsp;Counts&nbsp;the&nbsp;number&nbsp;of&nbsp;mouse&nbsp;clicks.</span></div></li>
<li><div class="src-line"><a name="a598"></a><span class="src-doc">&nbsp;*&nbsp;Drag&nbsp;and&nbsp;drop&nbsp;traces&nbsp;are&nbsp;removed.</span></div></li>
<li><div class="src-line"><a name="a599"></a><span class="src-doc">&nbsp;*&nbsp;</span><span class="src-doc-coretag">@param&nbsp;</span><span class="src-doc">&nbsp;&nbsp;</span><span class="src-doc-type">array&nbsp;</span><span class="src-doc">&nbsp;</span><span class="src-doc-var">$xclicks&nbsp;</span><span class="src-doc">&nbsp;&nbsp;horizontal&nbsp;click&nbsp;coordinates</span></div></li>
<li><div class="src-line"><a name="a600"></a><span class="src-doc">&nbsp;*&nbsp;</span><span class="src-doc-coretag">@param&nbsp;</span><span class="src-doc">&nbsp;&nbsp;</span><span class="src-doc-type">array&nbsp;</span><span class="src-doc">&nbsp;</span><span class="src-doc-var">$yclicks&nbsp;</span><span class="src-doc">&nbsp;&nbsp;vertical&nbsp;click&nbsp;coordinates</span></div></li>
<li><div class="src-line"><a name="a601"></a><span class="src-doc">&nbsp;*&nbsp;</span><span class="src-doc-coretag">@return&nbsp;</span><span class="src-doc">&nbsp;</span><span class="src-doc-type">int&nbsp;</span><span class="src-doc">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;number&nbsp;of&nbsp;clicks</span></div></li>
<li><div class="src-line"><a name="a602"></a><span class="src-doc">&nbsp;*/</span></div></li>
<li><div class="src-line"><a name="a603"></a><span class="src-key">function&nbsp;</span><a href="../smt2/_functions.php.html#functioncount_clicks">count_clicks</a><span class="src-sym">(</span><span class="src-var">$xclicks</span><span class="src-sym">,&nbsp;</span><span class="src-var">$yclicks</span><span class="src-sym">)</span></div></li>
<li><div class="src-line"><a name="a604"></a><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a605"></a>&nbsp;&nbsp;<span class="src-var">$numClicks&nbsp;</span>=&nbsp;<span class="src-num">0</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a606"></a>&nbsp;&nbsp;</div></li>
<li><div class="src-line"><a name="a607"></a>&nbsp;&nbsp;<span class="src-comm">//&nbsp;check</span></div></li>
<li><div class="src-line"><a name="a608"></a>&nbsp;&nbsp;<span class="src-key">if&nbsp;</span><span class="src-sym">(</span><span class="src-sym">!</span><a href="http://www.php.net/is_array">is_array</a><span class="src-sym">(</span><span class="src-var">$xclicks</span><span class="src-sym">))&nbsp;</span><span class="src-sym">{&nbsp;</span><span class="src-var">$xclicks&nbsp;</span>=&nbsp;<a href="../smt2/_functions.php.html#functionarray_null">array_null</a><span class="src-sym">(</span><span class="src-var">$xclicks</span><span class="src-sym">)</span><span class="src-sym">;&nbsp;</span><span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a609"></a>&nbsp;&nbsp;<span class="src-key">if&nbsp;</span><span class="src-sym">(</span><span class="src-sym">!</span><a href="http://www.php.net/is_array">is_array</a><span class="src-sym">(</span><span class="src-var">$yclicks</span><span class="src-sym">))&nbsp;</span><span class="src-sym">{&nbsp;</span><span class="src-var">$yclicks&nbsp;</span>=&nbsp;<a href="../smt2/_functions.php.html#functionarray_null">array_null</a><span class="src-sym">(</span><span class="src-var">$yclicks</span><span class="src-sym">)</span><span class="src-sym">;&nbsp;</span><span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a610"></a>&nbsp;&nbsp;</div></li>
<li><div class="src-line"><a name="a611"></a>&nbsp;&nbsp;<span class="src-var">$maxCount&nbsp;</span>=&nbsp;<a href="http://www.php.net/count">count</a><span class="src-sym">(</span><span class="src-var">$xclicks</span><span class="src-sym">)&nbsp;</span>-&nbsp;<span class="src-num">1</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a612"></a>&nbsp;&nbsp;<span class="src-comm">//&nbsp;transform&nbsp;points</span></div></li>
<li><div class="src-line"><a name="a613"></a>&nbsp;&nbsp;<span class="src-key">foreach&nbsp;</span><span class="src-sym">(</span><span class="src-var">$xclicks&nbsp;</span><span class="src-key">as&nbsp;</span><span class="src-var">$i&nbsp;</span>=&gt;&nbsp;<span class="src-var">$value</span><span class="src-sym">)</span></div></li>
<li><div class="src-line"><a name="a614"></a>&nbsp;&nbsp;<span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a615"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$p&nbsp;</span>=&nbsp;<span class="src-key">new&nbsp;</span><span class="src-id"><a href="../smt2/Point.html">Point</a></span><span class="src-sym">(</span><span class="src-var">$value</span><span class="src-sym">,&nbsp;</span><span class="src-var">$yclicks</span><span class="src-sym">[</span><span class="src-var">$i</span><span class="src-sym">]</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a616"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-comm">//&nbsp;check&nbsp;if&nbsp;next&nbsp;point&nbsp;exists</span></div></li>
<li><div class="src-line"><a name="a617"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-key">if&nbsp;</span><span class="src-sym">(</span><span class="src-var">$i&nbsp;</span>&gt;=&nbsp;<span class="src-var">$maxCount</span><span class="src-sym">)&nbsp;</span><span class="src-sym">{&nbsp;</span><span class="src-key">break</span><span class="src-sym">;&nbsp;</span><span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a618"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a619"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$q&nbsp;</span>=&nbsp;<span class="src-key">new&nbsp;</span><span class="src-id"><a href="../smt2/Point.html">Point</a></span><span class="src-sym">(</span><span class="src-var">$xclicks</span><span class="src-sym">[</span><span class="src-var">$i&nbsp;</span>+&nbsp;<span class="src-num">1</span><span class="src-sym">]</span><span class="src-sym">,&nbsp;</span><span class="src-var">$yclicks</span><span class="src-sym">[</span><span class="src-var">$i&nbsp;</span>+&nbsp;<span class="src-num">1</span><span class="src-sym">]</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a620"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-key">if&nbsp;</span><span class="src-sym">(</span><span class="src-var">$p</span><span class="src-sym">-&gt;</span><span class="src-id">getDistance</span><span class="src-sym">(</span><span class="src-var">$q</span><span class="src-sym">)&nbsp;</span>&gt;&nbsp;<span class="src-num">0&nbsp;</span>&amp;&amp;&nbsp;<span class="src-sym">!</span><span class="src-var">$q</span><span class="src-sym">-&gt;</span><span class="src-id">x</span><span class="src-sym">)&nbsp;</span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a621"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$numClicks</span>++<span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a622"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a623"></a>&nbsp;&nbsp;<span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a624"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a625"></a>&nbsp;&nbsp;<span class="src-key">return&nbsp;</span><span class="src-var">$numClicks</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a626"></a><span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a627"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</div></li>
<li><div class="src-line"><a name="a628"></a><span class="src-doc">/**</span></div></li>
<li><div class="src-line"><a name="a629"></a><span class="src-doc">&nbsp;*&nbsp;Makes&nbsp;an&nbsp;HTTP&nbsp;1.1&nbsp;compliant&nbsp;redirect.</span></div></li>
<li><div class="src-line"><a name="a630"></a><span class="src-doc">&nbsp;*&nbsp;Absolute&nbsp;URLs&nbsp;are&nbsp;required,&nbsp;though&nbsp;all&nbsp;modern&nbsp;browsers&nbsp;support&nbsp;relative&nbsp;URLs.</span></div></li>
<li><div class="src-line"><a name="a631"></a><span class="src-doc">&nbsp;*&nbsp;</span><span class="src-doc-coretag">@param&nbsp;</span><span class="src-doc">&nbsp;&nbsp;</span><span class="src-doc-type">string&nbsp;</span><span class="src-doc">&nbsp;&nbsp;&nbsp;</span><span class="src-doc-var">$path&nbsp;</span><span class="src-doc">&nbsp;where&nbsp;to&nbsp;go&nbsp;to,&nbsp;starting&nbsp;at&nbsp;server&nbsp;root&nbsp;(default:&nbsp;none)</span></div></li>
<li><div class="src-line"><a name="a632"></a><span class="src-doc">&nbsp;*/</span></div></li>
<li><div class="src-line"><a name="a633"></a><span class="src-key">function&nbsp;</span><a href="../smt2/_functions.php.html#functionredirect">redirect</a><span class="src-sym">(</span><span class="src-var">$path&nbsp;</span>=&nbsp;<span class="src-str">&quot;&quot;</span><span class="src-sym">)</span></div></li>
<li><div class="src-line"><a name="a634"></a><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a635"></a>&nbsp;&nbsp;<span class="src-var">$url&nbsp;</span>=&nbsp;<a href="../smt2/_functions.php.html#functionget_server_URL">get_server_URL</a><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a636"></a>&nbsp;&nbsp;</div></li>
<li><div class="src-line"><a name="a637"></a>&nbsp;&nbsp;<span class="src-key">if&nbsp;</span><span class="src-sym">(</span><span class="src-key">empty</span><span class="src-sym">(</span><span class="src-var">$path</span><span class="src-sym">))&nbsp;</span><span class="src-sym">{&nbsp;</span><span class="src-var">$path&nbsp;</span>=&nbsp;<span class="src-var">$url</span><span class="src-sym">;&nbsp;</span><span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a638"></a>&nbsp;&nbsp;<span class="src-comm">//&nbsp;check&nbsp;that&nbsp;server&nbsp;url&nbsp;is&nbsp;on&nbsp;the&nbsp;$path&nbsp;argument</span></div></li>
<li><div class="src-line"><a name="a639"></a>&nbsp;&nbsp;<span class="src-key">if&nbsp;</span><span class="src-sym">(</span><a href="http://www.php.net/strpos">strpos</a><span class="src-sym">(</span><span class="src-var">$path</span><span class="src-sym">,&nbsp;</span><span class="src-var">$url</span><span class="src-sym">)&nbsp;</span>===&nbsp;<span class="src-id">false</span><span class="src-sym">)&nbsp;</span><span class="src-sym">{&nbsp;</span><span class="src-var">$path&nbsp;</span>=&nbsp;<span class="src-var">$url</span>.<span class="src-var">$path</span><span class="src-sym">;&nbsp;</span><span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a640"></a>&nbsp;&nbsp;</div></li>
<li><div class="src-line"><a name="a641"></a>&nbsp;&nbsp;&nbsp;&nbsp;<a href="http://www.php.net/header">header</a><span class="src-sym">(</span><span class="src-str">&quot;Location:&nbsp;&quot;</span>.<span class="src-var">$path</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a642"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-key">exit</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a643"></a><span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a644"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a645"></a><span class="src-doc">/**</span></div></li>
<li><div class="src-line"><a name="a646"></a><span class="src-doc">&nbsp;*&nbsp;Gets&nbsp;the&nbsp;URL&nbsp;of&nbsp;current&nbsp;server&nbsp;(protocol&nbsp;+&nbsp;domain).</span></div></li>
<li><div class="src-line"><a name="a647"></a><span class="src-doc">&nbsp;*&nbsp;</span><span class="src-doc-coretag">@return&nbsp;</span><span class="src-doc">&nbsp;</span><span class="src-doc-type">string&nbsp;</span><span class="src-doc">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Full&nbsp;URL</span></div></li>
<li><div class="src-line"><a name="a648"></a><span class="src-doc">&nbsp;*/</span></div></li>
<li><div class="src-line"><a name="a649"></a><span class="src-key">function&nbsp;</span><a href="../smt2/_functions.php.html#functionget_server_URL">get_server_URL</a><span class="src-sym">(</span><span class="src-sym">)</span></div></li>
<li><div class="src-line"><a name="a650"></a><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a651"></a>&nbsp;&nbsp;<span class="src-comm">//$protocol&nbsp;=&nbsp;&quot;http://&quot;;</span></div></li>
<li><div class="src-line"><a name="a652"></a>&nbsp;&nbsp;<span class="src-var">$protocol&nbsp;</span>=&nbsp;<span class="src-str">&quot;http&quot;&nbsp;</span>.&nbsp;<span class="src-sym">((</span><span class="src-sym">!</span><span class="src-key">empty</span><span class="src-sym">(</span><span class="src-var">$_SERVER</span><span class="src-sym">[</span><span class="src-str">'HTTPS'</span><span class="src-sym">]</span><span class="src-sym">)&nbsp;</span>&amp;&amp;&nbsp;<span class="src-var">$_SERVER</span><span class="src-sym">[</span><span class="src-str">'HTTPS'</span><span class="src-sym">]&nbsp;</span>!=&nbsp;<span class="src-str">&quot;off&quot;</span><span class="src-sym">)&nbsp;</span>?&nbsp;<span class="src-str">&quot;s&quot;&nbsp;</span>:&nbsp;<span class="src-id">null</span><span class="src-sym">)&nbsp;</span>.&nbsp;<span class="src-str">&quot;://&quot;</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a653"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a654"></a>&nbsp;&nbsp;<span class="src-var">$host&nbsp;</span>=&nbsp;<span class="src-var">$_SERVER</span><span class="src-sym">[</span><span class="src-str">'HTTP_HOST'</span><span class="src-sym">]</span><span class="src-sym">;&nbsp;</span><span class="src-comm">//&nbsp;reliable&nbsp;in&nbsp;virtual&nbsp;hosts</span></div></li>
<li><div class="src-line"><a name="a655"></a>&nbsp;&nbsp;<span class="src-key">if&nbsp;</span><span class="src-sym">(</span><span class="src-key">empty</span><span class="src-sym">(</span><span class="src-var">$host</span><span class="src-sym">))&nbsp;</span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a656"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$host&nbsp;</span>=&nbsp;<span class="src-var">$_SERVER</span><span class="src-sym">[</span><span class="src-str">'SERVER_NAME'</span><span class="src-sym">]</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a657"></a>&nbsp;&nbsp;<span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a658"></a>&nbsp;&nbsp;</div></li>
<li><div class="src-line"><a name="a659"></a>&nbsp;&nbsp;<span class="src-key">return&nbsp;</span><span class="src-var">$protocol</span>.<span class="src-var">$host</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a660"></a><span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a661"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a662"></a><span class="src-doc">/**</span></div></li>
<li><div class="src-line"><a name="a663"></a><span class="src-doc">&nbsp;*&nbsp;Gets&nbsp;the&nbsp;full&nbsp;path&nbsp;to&nbsp;the&nbsp;current&nbsp;PHP&nbsp;file&nbsp;(protocol&nbsp;+&nbsp;domain&nbsp;+&nbsp;paths/to/file).</span></div></li>
<li><div class="src-line"><a name="a664"></a><span class="src-doc">&nbsp;*&nbsp;</span><span class="src-doc-coretag">@param&nbsp;</span><span class="src-doc">&nbsp;&nbsp;</span><span class="src-doc-type">boolean&nbsp;</span><span class="src-doc">&nbsp;</span><span class="src-doc-var">$fullURI&nbsp;</span><span class="src-doc">&nbsp;append&nbsp;the&nbsp;query&nbsp;string,&nbsp;if&nbsp;any&nbsp;(default:&nbsp;false)</span></div></li>
<li><div class="src-line"><a name="a665"></a><span class="src-doc">&nbsp;*&nbsp;</span><span class="src-doc-coretag">@return&nbsp;</span><span class="src-doc">&nbsp;</span><span class="src-doc-type">string&nbsp;</span><span class="src-doc">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Full&nbsp;URL</span></div></li>
<li><div class="src-line"><a name="a666"></a><span class="src-doc">&nbsp;*/</span></div></li>
<li><div class="src-line"><a name="a667"></a><span class="src-key">function&nbsp;</span><a href="../smt2/_functions.php.html#functionget_current_URL">get_current_URL</a><span class="src-sym">(</span><span class="src-var">$fullURI&nbsp;</span>=&nbsp;<span class="src-id">false</span><span class="src-sym">)</span></div></li>
<li><div class="src-line"><a name="a668"></a><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a669"></a>&nbsp;&nbsp;<span class="src-comm">//&nbsp;quick&nbsp;check:</span></div></li>
<li><div class="src-line"><a name="a670"></a>&nbsp;&nbsp;<span class="src-var">$url&nbsp;&nbsp;</span>=&nbsp;<a href="../smt2/_functions.php.html#functionget_server_URL">get_server_URL</a><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a671"></a>&nbsp;&nbsp;<span class="src-var">$url&nbsp;</span>.=&nbsp;<span class="src-var">$_SERVER</span><span class="src-sym">[</span><span class="src-str">'SCRIPT_NAME'</span><span class="src-sym">]</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a672"></a>&nbsp;&nbsp;<span class="src-key">if&nbsp;</span><span class="src-sym">(</span><span class="src-var">$fullURI</span><span class="src-sym">)&nbsp;</span><span class="src-sym">{&nbsp;</span><span class="src-var">$url&nbsp;</span>.=&nbsp;<span class="src-str">'?'</span>.<span class="src-var">$_SERVER</span><span class="src-sym">[</span><span class="src-str">'QUERY_STRING'</span><span class="src-sym">]</span><span class="src-sym">;&nbsp;</span><span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a673"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a674"></a>&nbsp;&nbsp;<span class="src-key">return&nbsp;</span><span class="src-var">$url</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a675"></a><span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a676"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a677"></a><span class="src-doc">/**&nbsp;</span></div></li>
<li><div class="src-line"><a name="a678"></a><span class="src-doc">&nbsp;*&nbsp;Gets&nbsp;the&nbsp;base&nbsp;path&nbsp;of&nbsp;a&nbsp;URL.</span></div></li>
<li><div class="src-line"><a name="a679"></a><span class="src-doc">&nbsp;*&nbsp;</span><span class="src-doc-coretag">@param&nbsp;</span><span class="src-doc">&nbsp;&nbsp;</span><span class="src-doc-type">string&nbsp;</span><span class="src-doc">&nbsp;</span><span class="src-doc-var">$url&nbsp;</span><span class="src-doc">&nbsp;input&nbsp;URL</span></div></li>
<li><div class="src-line"><a name="a680"></a><span class="src-doc">&nbsp;*&nbsp;</span><span class="src-doc-coretag">@return&nbsp;</span><span class="src-doc">&nbsp;</span><span class="src-doc-type">string&nbsp;</span><span class="src-doc">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Base&nbsp;URL</span></div></li>
<li><div class="src-line"><a name="a681"></a><span class="src-doc">&nbsp;*/</span></div></li>
<li><div class="src-line"><a name="a682"></a><span class="src-key">function&nbsp;</span><a href="../smt2/_functions.php.html#functionget_base">get_base</a><span class="src-sym">(</span><span class="src-var">$url</span><span class="src-sym">)</span></div></li>
<li><div class="src-line"><a name="a683"></a><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a684"></a>&nbsp;&nbsp;<span class="src-comm">//&nbsp;split&nbsp;url&nbsp;in&nbsp;dirs</span></div></li>
<li><div class="src-line"><a name="a685"></a>&nbsp;&nbsp;<span class="src-var">$paths&nbsp;</span>=&nbsp;<a href="http://www.php.net/explode">explode</a><span class="src-sym">(</span><span class="src-str">&quot;/&quot;</span><span class="src-sym">,&nbsp;</span><span class="src-var">$url</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a686"></a>&nbsp;&nbsp;<span class="src-comm">//&nbsp;short&nbsp;URLs&nbsp;like&nbsp;http://server.com&nbsp;should&nbsp;be&nbsp;fixed</span></div></li>
<li><div class="src-line"><a name="a687"></a>&nbsp;&nbsp;<span class="src-key">if&nbsp;</span><span class="src-sym">(</span><a href="http://www.php.net/count">count</a><span class="src-sym">(</span><span class="src-var">$paths</span><span class="src-sym">)&nbsp;</span>&gt;&nbsp;<span class="src-num">3</span><span class="src-sym">)&nbsp;</span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a688"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-comm">//&nbsp;remove&nbsp;last&nbsp;element,&nbsp;so&nbsp;we&nbsp;do&nbsp;not&nbsp;have&nbsp;to&nbsp;worry&nbsp;about&nbsp;the&nbsp;query&nbsp;string&nbsp;(?var1=value1&amp;var2=value2#anchor...)</span></div></li>
<li><div class="src-line"><a name="a689"></a>&nbsp;&nbsp;&nbsp;&nbsp;<a href="http://www.php.net/array_pop">array_pop</a><span class="src-sym">(</span><span class="src-var">$paths</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a690"></a>&nbsp;&nbsp;<span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a691"></a>&nbsp;&nbsp;<span class="src-comm">//&nbsp;and&nbsp;we&nbsp;have&nbsp;the&nbsp;BASE&nbsp;href</span></div></li>
<li><div class="src-line"><a name="a692"></a>&nbsp;&nbsp;<span class="src-var">$base&nbsp;</span>=&nbsp;<a href="http://www.php.net/implode">implode</a><span class="src-sym">(</span><span class="src-str">&quot;/&quot;</span><span class="src-sym">,&nbsp;</span><span class="src-var">$paths</span><span class="src-sym">)&nbsp;</span>.&nbsp;<span class="src-str">&quot;/&quot;</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a693"></a>&nbsp;&nbsp;</div></li>
<li><div class="src-line"><a name="a694"></a>&nbsp;&nbsp;<span class="src-key">return&nbsp;</span><span class="src-var">$base</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a695"></a><span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a696"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a697"></a><span class="src-doc">/**&nbsp;</span></div></li>
<li><div class="src-line"><a name="a698"></a><span class="src-doc">&nbsp;*&nbsp;Gets&nbsp;installed&nbsp;extensions&nbsp;priorities.</span></div></li>
<li><div class="src-line"><a name="a699"></a><span class="src-doc">&nbsp;*&nbsp;</span><span class="src-doc-coretag">@return&nbsp;</span><span class="src-doc">&nbsp;</span><span class="src-doc-type">array&nbsp;</span><span class="src-doc">&nbsp;&nbsp;Array&nbsp;with&nbsp;keys:&nbsp;dir&nbsp;name&nbsp;(string)&nbsp;=&gt;&nbsp;order&nbsp;priority&nbsp;(int)</span></div></li>
<li><div class="src-line"><a name="a700"></a><span class="src-doc">&nbsp;*/</span></div></li>
<li><div class="src-line"><a name="a701"></a><span class="src-key">function&nbsp;</span><a href="../smt2/_functions.php.html#functionget_exts_order">get_exts_order</a><span class="src-sym">(</span><span class="src-sym">)&nbsp;</span></div></li>
<li><div class="src-line"><a name="a702"></a><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a703"></a>&nbsp;&nbsp;<span class="src-var">$exts&nbsp;</span>=&nbsp;<a href="../smt2/_functions.db.php.html#functiondb_select_all">db_select_all</a><span class="src-sym">(</span><span class="src-id">TBL_PREFIX</span>.<span class="src-id"><a href="../smt2/_define.php.html#defineTBL_EXTS">TBL_EXTS</a></span><span class="src-sym">,&nbsp;</span><span class="src-str">&quot;*&quot;</span><span class="src-sym">,&nbsp;</span><span class="src-str">&quot;1&quot;</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a704"></a>&nbsp;&nbsp;</div></li>
<li><div class="src-line"><a name="a705"></a>&nbsp;&nbsp;<span class="src-key">foreach&nbsp;</span><span class="src-sym">(</span><span class="src-var">$exts&nbsp;</span><span class="src-key">as&nbsp;</span><span class="src-var">$ext</span><span class="src-sym">)&nbsp;</span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a706"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$priority</span><span class="src-sym">[&nbsp;</span><span class="src-var">$ext</span><span class="src-sym">[</span><span class="src-str">'dir'</span><span class="src-sym">]&nbsp;]&nbsp;</span>=&nbsp;(int)&nbsp;<span class="src-var">$ext</span><span class="src-sym">[</span><span class="src-str">'priority'</span><span class="src-sym">]</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a707"></a>&nbsp;&nbsp;<span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a708"></a>&nbsp;&nbsp;<span class="src-comm">//&nbsp;sort&nbsp;maintaining&nbsp;index&nbsp;association</span></div></li>
<li><div class="src-line"><a name="a709"></a>&nbsp;&nbsp;<span class="src-key">if&nbsp;</span><span class="src-sym">(</span><a href="http://www.php.net/max">max</a><span class="src-sym">(</span><span class="src-var">$priority</span><span class="src-sym">)&nbsp;</span>&gt;&nbsp;<span class="src-num">0</span><span class="src-sym">)&nbsp;</span><span class="src-sym">{&nbsp;</span><a href="http://www.php.net/asort">asort</a><span class="src-sym">(</span><span class="src-var">$priority</span><span class="src-sym">)</span><span class="src-sym">;&nbsp;</span><span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a710"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a711"></a>&nbsp;&nbsp;<span class="src-key">return&nbsp;</span><span class="src-var">$priority</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a712"></a><span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a713"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a714"></a><span class="src-doc">/**&nbsp;</span></div></li>
<li><div class="src-line"><a name="a715"></a><span class="src-doc">&nbsp;*&nbsp;Gets&nbsp;all&nbsp;available&nbsp;CMS&nbsp;sections.</span></div></li>
<li><div class="src-line"><a name="a716"></a><span class="src-doc">&nbsp;*&nbsp;</span><span class="src-doc-coretag">@return&nbsp;</span><span class="src-doc">&nbsp;</span><span class="src-doc-type">array&nbsp;</span><span class="src-doc">&nbsp;&nbsp;Array&nbsp;of&nbsp;strings&nbsp;(sections)</span></div></li>
<li><div class="src-line"><a name="a717"></a><span class="src-doc">&nbsp;*/</span></div></li>
<li><div class="src-line"><a name="a718"></a><span class="src-key">function&nbsp;</span><a href="../smt2/_functions.php.html#functionext_available">ext_available</a><span class="src-sym">(</span><span class="src-sym">)&nbsp;</span></div></li>
<li><div class="src-line"><a name="a719"></a><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a720"></a>&nbsp;&nbsp;<span class="src-var">$dir&nbsp;</span>=&nbsp;<span class="src-id">INC_PATH</span>.<span class="src-str">'ext'</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a721"></a>&nbsp;&nbsp;<span class="src-var">$ext&nbsp;</span>=&nbsp;<span class="src-key">array</span><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a722"></a>&nbsp;&nbsp;<span class="src-key">if&nbsp;</span><span class="src-sym">(</span><span class="src-var">$handle&nbsp;</span>=&nbsp;<a href="http://www.php.net/opendir">opendir</a><span class="src-sym">(</span><span class="src-var">$dir</span><span class="src-sym">))&nbsp;</span></div></li>
<li><div class="src-line"><a name="a723"></a>&nbsp;&nbsp;<span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a724"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-key">while&nbsp;</span><span class="src-sym">(</span><span class="src-id">false&nbsp;</span>!==&nbsp;<span class="src-sym">(</span><span class="src-var">$file&nbsp;</span>=&nbsp;<a href="http://www.php.net/readdir">readdir</a><span class="src-sym">(</span><span class="src-var">$handle</span><span class="src-sym">)))&nbsp;</span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a725"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-comm">//&nbsp;look&nbsp;for&nbsp;available&nbsp;module&nbsp;extensions</span></div></li>
<li><div class="src-line"><a name="a726"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-key">if&nbsp;</span><span class="src-sym">(</span><span class="src-var">$file&nbsp;</span>!=&nbsp;<span class="src-str">&quot;.&quot;&nbsp;</span>&amp;&amp;&nbsp;<span class="src-var">$file&nbsp;</span>!=&nbsp;<span class="src-str">&quot;..&quot;&nbsp;</span>&amp;&amp;&nbsp;<a href="http://www.php.net/is_dir">is_dir</a><span class="src-sym">(</span><span class="src-var">$dir</span>.<span class="src-str">'/'</span>.<span class="src-var">$file</span><span class="src-sym">))&nbsp;</span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a727"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$ext</span><span class="src-sym">[</span><span class="src-sym">]&nbsp;</span>=&nbsp;<span class="src-var">$file</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a728"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a729"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a730"></a>&nbsp;&nbsp;&nbsp;&nbsp;<a href="http://www.php.net/closedir">closedir</a><span class="src-sym">(</span><span class="src-var">$handle</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a731"></a>&nbsp;&nbsp;<span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a732"></a>&nbsp;&nbsp;</div></li>
<li><div class="src-line"><a name="a733"></a>&nbsp;&nbsp;<span class="src-key">return&nbsp;</span><span class="src-var">$ext</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a734"></a><span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a735"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a736"></a><span class="src-doc">/**&nbsp;</span></div></li>
<li><div class="src-line"><a name="a737"></a><span class="src-doc">&nbsp;*&nbsp;Gives&nbsp;format&nbsp;to&nbsp;CMS&nbsp;sections.</span></div></li>
<li><div class="src-line"><a name="a738"></a><span class="src-doc">&nbsp;*&nbsp;</span><span class="src-doc-coretag">@return&nbsp;</span><span class="src-doc">&nbsp;</span><span class="src-doc-type">string&nbsp;</span><span class="src-doc">&nbsp;Formatted&nbsp;output&nbsp;list&nbsp;(LI&nbsp;elements)</span></div></li>
<li><div class="src-line"><a name="a739"></a><span class="src-doc">&nbsp;*/</span></div></li>
<li><div class="src-line"><a name="a740"></a><span class="src-key">function&nbsp;</span><a href="../smt2/_functions.php.html#functionext_format">ext_format</a><span class="src-sym">(</span><span class="src-sym">)</span></div></li>
<li><div class="src-line"><a name="a741"></a><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a742"></a>&nbsp;&nbsp;<span class="src-key">if&nbsp;</span><span class="src-sym">(</span><span class="src-sym">!</span>isset<span class="src-sym">(</span><span class="src-var">$_SESSION</span><span class="src-sym">[</span><span class="src-str">'allowed'</span><span class="src-sym">]</span><span class="src-sym">))&nbsp;</span><span class="src-key">return&nbsp;</span><span class="src-id">false</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a743"></a>&nbsp;&nbsp;</div></li>
<li><div class="src-line"><a name="a744"></a>&nbsp;&nbsp;<span class="src-var">$current&nbsp;</span>=&nbsp;<a href="../smt2/_functions.php.html#functionext_name">ext_name</a><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a745"></a>&nbsp;&nbsp;<span class="src-comm">//&nbsp;check&nbsp;priority</span></div></li>
<li><div class="src-line"><a name="a746"></a>&nbsp;&nbsp;<span class="src-var">$prioritized&nbsp;</span>=&nbsp;<a href="../smt2/_functions.php.html#functionget_exts_order">get_exts_order</a><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a747"></a>&nbsp;&nbsp;<span class="src-comm">//&nbsp;loop&nbsp;through&nbsp;available&nbsp;sections</span></div></li>
<li><div class="src-line"><a name="a748"></a>&nbsp;&nbsp;<span class="src-var">$list&nbsp;</span>=&nbsp;<span class="src-str">&quot;&quot;</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a749"></a>&nbsp;&nbsp;<span class="src-key">foreach&nbsp;</span><span class="src-sym">(</span><span class="src-var">$prioritized&nbsp;</span><span class="src-key">as&nbsp;</span><span class="src-var">$dir&nbsp;</span>=&gt;&nbsp;<span class="src-var">$priority</span><span class="src-sym">)&nbsp;</span></div></li>
<li><div class="src-line"><a name="a750"></a>&nbsp;&nbsp;<span class="src-sym">{&nbsp;</span></div></li>
<li><div class="src-line"><a name="a751"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-key">if&nbsp;</span><span class="src-sym">(</span><span class="src-sym">!</span><a href="http://www.php.net/in_array">in_array</a><span class="src-sym">(</span><span class="src-var">$dir</span><span class="src-sym">,&nbsp;</span><span class="src-var">$_SESSION</span><span class="src-sym">[</span><span class="src-str">'allowed'</span><span class="src-sym">]</span><span class="src-sym">))&nbsp;</span><span class="src-sym">{&nbsp;</span><span class="src-key">continue</span><span class="src-sym">;&nbsp;</span><span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a752"></a>&nbsp;&nbsp;&nbsp;&nbsp;</div></li>
<li><div class="src-line"><a name="a753"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$css&nbsp;</span>=&nbsp;<span class="src-sym">(</span><span class="src-var">$current&nbsp;</span>==&nbsp;<span class="src-var">$dir</span><span class="src-sym">)&nbsp;</span>?&nbsp;<span class="src-str">'&nbsp;class=&quot;current&quot;'&nbsp;</span>:&nbsp;<span class="src-id">null</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a754"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$href&nbsp;</span>=&nbsp;<span class="src-id"><a href="../smt2/_define.php.html#defineADMIN_PATH">ADMIN_PATH</a></span>.<span class="src-str">'ext/'</span>.<span class="src-var">$dir</span>.<span class="src-str">'/'</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a755"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$list&nbsp;</span>.=&nbsp;<span class="src-str">'&lt;li'</span>.<span class="src-var">$css</span>.<span class="src-str">'&gt;&lt;a&nbsp;href=&quot;'</span>.<span class="src-var">$href</span>.<span class="src-str">'&quot;&gt;'</span>.<a href="http://www.php.net/ucfirst">ucfirst</a><span class="src-sym">(</span><a href="../smt2/_functions.php.html#functionfilename_to_str">filename_to_str</a><span class="src-sym">(</span><span class="src-var">$dir</span><span class="src-sym">))</span>.<span class="src-str">'&lt;/a&gt;&lt;/li&gt;'</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a756"></a>&nbsp;&nbsp;<span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a757"></a>&nbsp;&nbsp;</div></li>
<li><div class="src-line"><a name="a758"></a>&nbsp;&nbsp;<span class="src-key">return&nbsp;</span><span class="src-var">$list</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a759"></a><span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a760"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a761"></a><span class="src-doc">/**&nbsp;</span></div></li>
<li><div class="src-line"><a name="a762"></a><span class="src-doc">&nbsp;*&nbsp;Gets&nbsp;the&nbsp;current&nbsp;CMS&nbsp;extension&nbsp;name.</span></div></li>
<li><div class="src-line"><a name="a763"></a><span class="src-doc">&nbsp;*&nbsp;</span><span class="src-doc-coretag">@return&nbsp;</span><span class="src-doc">&nbsp;</span><span class="src-doc-type">string&nbsp;</span><span class="src-doc">&nbsp;&nbsp;&nbsp;Section&nbsp;name</span></div></li>
<li><div class="src-line"><a name="a764"></a><span class="src-doc">&nbsp;*/</span></div></li>
<li><div class="src-line"><a name="a765"></a><span class="src-key">function&nbsp;</span><a href="../smt2/_functions.php.html#functionext_name">ext_name</a><span class="src-sym">(</span><span class="src-sym">)&nbsp;</span></div></li>
<li><div class="src-line"><a name="a766"></a><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a767"></a>&nbsp;&nbsp;<span class="src-var">$ext&nbsp;</span>=&nbsp;<a href="http://www.php.net/explode">explode</a><span class="src-sym">(</span><span class="src-str">&quot;/&quot;</span><span class="src-sym">,&nbsp;</span><a href="http://www.php.net/dirname">dirname</a><span class="src-sym">(</span><span class="src-var">$_SERVER</span><span class="src-sym">[</span><span class="src-str">'PHP_SELF'</span><span class="src-sym">]</span><span class="src-sym">))</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a768"></a>&nbsp;&nbsp;</div></li>
<li><div class="src-line"><a name="a769"></a>&nbsp;&nbsp;<span class="src-key">return&nbsp;</span><span class="src-var">$ext</span><span class="src-sym">[&nbsp;</span><a href="http://www.php.net/count">count</a><span class="src-sym">(</span><span class="src-var">$ext</span><span class="src-sym">)&nbsp;</span>-&nbsp;<span class="src-num">1&nbsp;</span><span class="src-sym">]</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a770"></a><span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a771"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a772"></a><span class="src-doc">/**&nbsp;</span></div></li>
<li><div class="src-line"><a name="a773"></a><span class="src-doc">&nbsp;*&nbsp;Assigns&nbsp;a&nbsp;valid&nbsp;filename&nbsp;to&nbsp;a&nbsp;given&nbsp;string:&nbsp;only&nbsp;alphanumeric&nbsp;chars.&nbsp;Spaces&nbsp;are&nbsp;converted&nbsp;to&nbsp;dashes.</span></div></li>
<li><div class="src-line"><a name="a774"></a><span class="src-doc">&nbsp;*&nbsp;</span><span class="src-doc-coretag">@param&nbsp;</span><span class="src-doc">&nbsp;&nbsp;</span><span class="src-doc-type">string&nbsp;</span><span class="src-doc">&nbsp;</span><span class="src-doc-var">$string&nbsp;</span><span class="src-doc">&nbsp;&nbsp;input&nbsp;string</span></div></li>
<li><div class="src-line"><a name="a775"></a><span class="src-doc">&nbsp;*&nbsp;</span><span class="src-doc-coretag">@return&nbsp;</span><span class="src-doc">&nbsp;</span><span class="src-doc-type">string&nbsp;</span><span class="src-doc">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Normalized&nbsp;String</span></div></li>
<li><div class="src-line"><a name="a776"></a><span class="src-doc">&nbsp;*/</span></div></li>
<li><div class="src-line"><a name="a777"></a><span class="src-key">function&nbsp;</span><a href="../smt2/_functions.php.html#functionstr_to_filename">str_to_filename</a><span class="src-sym">(</span><span class="src-var">$string</span><span class="src-sym">)&nbsp;</span></div></li>
<li><div class="src-line"><a name="a778"></a><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a779"></a>&nbsp;&nbsp;<span class="src-comm">//&nbsp;remove&nbsp;non&nbsp;alphanumeric&nbsp;chars</span></div></li>
<li><div class="src-line"><a name="a780"></a>&nbsp;&nbsp;<span class="src-var">$string&nbsp;</span>=&nbsp;<a href="http://www.php.net/preg_replace">preg_replace</a><span class="src-sym">(</span><span class="src-str">'/[^a-z0-9A-Z\s]+/'</span><span class="src-sym">,&nbsp;</span><span class="src-str">''</span><span class="src-sym">,&nbsp;</span><a href="http://www.php.net/strtolower">strtolower</a><span class="src-sym">(</span><span class="src-var">$string</span><span class="src-sym">))</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a781"></a>&nbsp;&nbsp;<span class="src-comm">//&nbsp;now&nbsp;convert&nbsp;spaces&nbsp;to&nbsp;dashes</span></div></li>
<li><div class="src-line"><a name="a782"></a>&nbsp;&nbsp;<span class="src-var">$string&nbsp;</span>=&nbsp;<a href="http://www.php.net/str_replace">str_replace</a><span class="src-sym">(</span><span class="src-str">&quot;&nbsp;&quot;</span><span class="src-sym">,&nbsp;</span><span class="src-str">&quot;-&quot;</span><span class="src-sym">,&nbsp;</span><span class="src-var">$string</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a783"></a>&nbsp;&nbsp;</div></li>
<li><div class="src-line"><a name="a784"></a>&nbsp;&nbsp;<span class="src-key">return&nbsp;</span><span class="src-var">$string</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a785"></a><span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a786"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a787"></a><span class="src-doc">/**&nbsp;</span></div></li>
<li><div class="src-line"><a name="a788"></a><span class="src-doc">&nbsp;*&nbsp;Reverse&nbsp;function&nbsp;for&nbsp;str_to_filename.&nbsp;Dashes&nbsp;are&nbsp;converted&nbsp;to&nbsp;spaces.</span></div></li>
<li><div class="src-line"><a name="a789"></a><span class="src-doc">&nbsp;*&nbsp;</span><span class="src-doc-coretag">@param&nbsp;</span><span class="src-doc">&nbsp;&nbsp;</span><span class="src-doc-type">string&nbsp;</span><span class="src-doc">&nbsp;</span><span class="src-doc-var">$string&nbsp;</span><span class="src-doc">&nbsp;&nbsp;normalized&nbsp;String</span></div></li>
<li><div class="src-line"><a name="a790"></a><span class="src-doc">&nbsp;*&nbsp;</span><span class="src-doc-coretag">@return&nbsp;</span><span class="src-doc">&nbsp;</span><span class="src-doc-type">string&nbsp;</span><span class="src-doc">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Output&nbsp;String</span></div></li>
<li><div class="src-line"><a name="a791"></a><span class="src-doc">&nbsp;*/</span></div></li>
<li><div class="src-line"><a name="a792"></a><span class="src-key">function&nbsp;</span><a href="../smt2/_functions.php.html#functionfilename_to_str">filename_to_str</a><span class="src-sym">(</span><span class="src-var">$string</span><span class="src-sym">)&nbsp;</span></div></li>
<li><div class="src-line"><a name="a793"></a><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a794"></a>&nbsp;&nbsp;<span class="src-comm">//&nbsp;now&nbsp;convert&nbsp;dashes&nbsp;to&nbsp;spaces&nbsp;</span></div></li>
<li><div class="src-line"><a name="a795"></a>&nbsp;&nbsp;<span class="src-var">$string&nbsp;</span>=&nbsp;<a href="http://www.php.net/str_replace">str_replace</a><span class="src-sym">(</span><span class="src-str">&quot;-&quot;</span><span class="src-sym">,&nbsp;</span><span class="src-str">&quot;&nbsp;&quot;</span><span class="src-sym">,&nbsp;</span><span class="src-var">$string</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a796"></a>&nbsp;&nbsp;</div></li>
<li><div class="src-line"><a name="a797"></a>&nbsp;&nbsp;<span class="src-key">return&nbsp;</span><span class="src-var">$string</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a798"></a><span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a799"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a800"></a><span class="src-doc">/**&nbsp;</span></div></li>
<li><div class="src-line"><a name="a801"></a><span class="src-doc">&nbsp;*&nbsp;Adds&nbsp;$element&nbsp;tags&nbsp;to&nbsp;all&nbsp;CMS&nbsp;extensions&nbsp;header.</span></div></li>
<li><div class="src-line"><a name="a802"></a><span class="src-doc">&nbsp;*&nbsp;</span><span class="src-doc-coretag">@param&nbsp;</span><span class="src-doc">&nbsp;&nbsp;</span><span class="src-doc-type">mixed&nbsp;</span><span class="src-doc">&nbsp;&nbsp;</span><span class="src-doc-var">$element&nbsp;</span><span class="src-doc">&nbsp;HTML&nbsp;code&nbsp;to&nbsp;insert&nbsp;in&nbsp;the&nbsp;HEAD&nbsp;of&nbsp;any&nbsp;CMS&nbsp;section&nbsp;(&lt;style&gt;,&nbsp;&lt;script&gt;,&nbsp;etc.).&nbsp;Can&nbsp;be&nbsp;a&nbsp;single&nbsp;string&nbsp;or&nbsp;an&nbsp;Array</span></div></li>
<li><div class="src-line"><a name="a803"></a><span class="src-doc">&nbsp;*&nbsp;</span><span class="src-doc-coretag">@global&nbsp;</span><span class="src-doc">&nbsp;</span><span class="src-doc-type">array&nbsp;</span><span class="src-doc">&nbsp;&nbsp;</span><span class="src-doc-var">$_headAdded&nbsp;</span></div></li>
<li><div class="src-line"><a name="a804"></a><span class="src-doc">&nbsp;*/</span></div></li>
<li><div class="src-line"><a name="a805"></a><span class="src-key">function&nbsp;</span><a href="../smt2/_functions.php.html#functionadd_head">add_head</a><span class="src-sym">(</span><span class="src-var">$element</span><span class="src-sym">)&nbsp;</span></div></li>
<li><div class="src-line"><a name="a806"></a><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a807"></a>&nbsp;&nbsp;<span class="src-key">global&nbsp;</span><a href="../smt2/_functions.php.html#global$_headAdded">$_headAdded</a><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a808"></a>&nbsp;&nbsp;</div></li>
<li><div class="src-line"><a name="a809"></a>&nbsp;&nbsp;<span class="src-key">if&nbsp;</span><span class="src-sym">(</span><span class="src-sym">!</span><span class="src-var">$element</span><span class="src-sym">)&nbsp;</span><span class="src-key">return</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a810"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a811"></a>&nbsp;&nbsp;<span class="src-key">if&nbsp;</span><span class="src-sym">(</span><a href="http://www.php.net/is_array">is_array</a><span class="src-sym">(</span><span class="src-var">$element</span><span class="src-sym">))&nbsp;</span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a812"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-key">foreach&nbsp;</span><span class="src-sym">(</span><span class="src-var">$element&nbsp;</span><span class="src-key">as&nbsp;</span><span class="src-var">$value</span><span class="src-sym">)&nbsp;</span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a813"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$_headAdded</span><span class="src-sym">[</span><span class="src-sym">]&nbsp;</span>=&nbsp;<span class="src-var">$value</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a814"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a815"></a>&nbsp;&nbsp;<span class="src-sym">}&nbsp;</span><span class="src-key">else&nbsp;</span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a816"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$_headAdded</span><span class="src-sym">[</span><span class="src-sym">]&nbsp;</span>=&nbsp;<span class="src-var">$element</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a817"></a>&nbsp;&nbsp;<span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a818"></a><span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a819"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a820"></a><span class="src-doc">/**&nbsp;</span></div></li>
<li><div class="src-line"><a name="a821"></a><span class="src-doc">&nbsp;*&nbsp;Displays&nbsp;a&nbsp;&lt;noscript&gt;&nbsp;warning&nbsp;message.&nbsp;Useful&nbsp;for&nbsp;those&nbsp;extensions&nbsp;that&nbsp;require&nbsp;JavaScript&nbsp;functionality.</span></div></li>
<li><div class="src-line"><a name="a822"></a><span class="src-doc">&nbsp;*&nbsp;</span><span class="src-doc-coretag">@param&nbsp;</span><span class="src-doc">&nbsp;&nbsp;</span><span class="src-doc-type">string&nbsp;</span><span class="src-doc">&nbsp;</span><span class="src-doc-var">$msg&nbsp;</span><span class="src-doc">&nbsp;&nbsp;&nbsp;custom&nbsp;warning&nbsp;message.&nbsp;Default:&nbsp;&quot;Please&nbsp;enable&nbsp;JavaScript&nbsp;in&nbsp;order&nbsp;to&nbsp;work&nbsp;on&nbsp;this&nbsp;section.&quot;</span></div></li>
<li><div class="src-line"><a name="a823"></a><span class="src-doc">&nbsp;*&nbsp;</span><span class="src-doc-coretag">@return&nbsp;</span><span class="src-doc">&nbsp;</span><span class="src-doc-type">string&nbsp;</span><span class="src-doc">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Message&nbsp;wrapped&nbsp;in&nbsp;a&nbsp;&lt;noscript&gt;&nbsp;tag</span></div></li>
<li><div class="src-line"><a name="a824"></a><span class="src-doc">&nbsp;*/</span></div></li>
<li><div class="src-line"><a name="a825"></a><span class="src-key">function&nbsp;</span><a href="../smt2/_functions.php.html#functioncheck_noscript">check_noscript</a><span class="src-sym">(</span><span class="src-var">$msg&nbsp;</span>=&nbsp;<span class="src-str">&quot;&quot;</span><span class="src-sym">)&nbsp;</span></div></li>
<li><div class="src-line"><a name="a826"></a><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a827"></a>&nbsp;&nbsp;<span class="src-key">global&nbsp;</span><a href="../smt2/_messages.php.html#global$_displayType">$_displayType</a><span class="src-sym">,&nbsp;</span><a href="../smt2/_messages.php.html#global$_notifyMsg">$_notifyMsg</a><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a828"></a>&nbsp;&nbsp;</div></li>
<li><div class="src-line"><a name="a829"></a>&nbsp;&nbsp;<span class="src-key">if&nbsp;</span><span class="src-sym">(</span><span class="src-key">empty</span><span class="src-sym">(</span><span class="src-var">$msg</span><span class="src-sym">))&nbsp;</span><span class="src-var">$msg&nbsp;</span>=&nbsp;<span class="src-var">$_notifyMsg</span><span class="src-sym">[</span><span class="src-str">&quot;NOSCRIPT&quot;</span><span class="src-sym">]</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a830"></a>&nbsp;&nbsp;</div></li>
<li><div class="src-line"><a name="a831"></a>&nbsp;&nbsp;<span class="src-key">return&nbsp;</span><span class="src-str">'&lt;noscript&gt;'</span>.<a href="../smt2/_functions.php.html#functiondisplay_text">display_text</a><span class="src-sym">(</span><span class="src-var">$_displayType</span><span class="src-sym">[</span><span class="src-str">&quot;WARNING&quot;</span><span class="src-sym">]</span><span class="src-sym">,&nbsp;</span><span class="src-var">$msg</span><span class="src-sym">)</span>.<span class="src-str">'&lt;/noscript&gt;'</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a832"></a><span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a833"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a834"></a><span class="src-doc">/**&nbsp;</span></div></li>
<li><div class="src-line"><a name="a835"></a><span class="src-doc">&nbsp;*&nbsp;Count&nbsp;files&nbsp;in&nbsp;a&nbsp;dir.&nbsp;This&nbsp;function&nbsp;skip&nbsp;directories,&nbsp;and&nbsp;it&nbsp;is&nbsp;not&nbsp;recursive.</span></div></li>
<li><div class="src-line"><a name="a836"></a><span class="src-doc">&nbsp;*&nbsp;By&nbsp;now&nbsp;it&nbsp;is&nbsp;only&nbsp;used&nbsp;to&nbsp;check&nbsp;the&nbsp;cache&nbsp;logs.</span></div></li>
<li><div class="src-line"><a name="a837"></a><span class="src-doc">&nbsp;*&nbsp;</span><span class="src-doc-coretag">@param&nbsp;</span><span class="src-doc">&nbsp;&nbsp;</span><span class="src-doc-type">string&nbsp;</span><span class="src-doc">&nbsp;</span><span class="src-doc-var">$dir&nbsp;</span><span class="src-doc">&nbsp;&nbsp;&nbsp;the&nbsp;directory&nbsp;to&nbsp;read&nbsp;files&nbsp;from</span></div></li>
<li><div class="src-line"><a name="a838"></a><span class="src-doc">&nbsp;*&nbsp;</span><span class="src-doc-coretag">@return&nbsp;</span><span class="src-doc">&nbsp;</span><span class="src-doc-type">int&nbsp;</span><span class="src-doc">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Number&nbsp;of&nbsp;files</span></div></li>
<li><div class="src-line"><a name="a839"></a><span class="src-doc">&nbsp;*/</span></div></li>
<li><div class="src-line"><a name="a840"></a><span class="src-key">function&nbsp;</span><a href="../smt2/_functions.php.html#functioncount_dir_files">count_dir_files</a><span class="src-sym">(</span><span class="src-var">$dir</span><span class="src-sym">)&nbsp;</span></div></li>
<li><div class="src-line"><a name="a841"></a><span class="src-sym">{&nbsp;&nbsp;</span></div></li>
<li><div class="src-line"><a name="a842"></a>&nbsp;&nbsp;<span class="src-var">$count&nbsp;</span>=&nbsp;<span class="src-num">0</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a843"></a>&nbsp;&nbsp;<span class="src-key">if&nbsp;</span><span class="src-sym">(</span><span class="src-var">$handle&nbsp;</span>=&nbsp;<a href="http://www.php.net/opendir">opendir</a><span class="src-sym">(</span><span class="src-var">$dir</span><span class="src-sym">))&nbsp;</span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a844"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-key">while&nbsp;</span><span class="src-sym">(</span><span class="src-id">false&nbsp;</span>!==&nbsp;<span class="src-sym">(</span><span class="src-var">$file&nbsp;</span>=&nbsp;<a href="http://www.php.net/readdir">readdir</a><span class="src-sym">(</span><span class="src-var">$handle</span><span class="src-sym">)))&nbsp;</span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a845"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-key">if&nbsp;</span><span class="src-sym">(</span><span class="src-var">$file&nbsp;</span>!=&nbsp;<span class="src-str">&quot;.&quot;&nbsp;</span>&amp;&amp;&nbsp;<span class="src-var">$file&nbsp;</span>!=&nbsp;<span class="src-str">&quot;..&quot;&nbsp;</span>&amp;&amp;&nbsp;<a href="http://www.php.net/is_file">is_file</a><span class="src-sym">(</span><span class="src-var">$dir</span>.<span class="src-str">'/'</span>.<span class="src-var">$file</span><span class="src-sym">))&nbsp;</span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a846"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$count</span>++<span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a847"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a848"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a849"></a>&nbsp;&nbsp;&nbsp;&nbsp;<a href="http://www.php.net/closedir">closedir</a><span class="src-sym">(</span><span class="src-var">$handle</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a850"></a>&nbsp;&nbsp;<span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a851"></a>&nbsp;&nbsp;</div></li>
<li><div class="src-line"><a name="a852"></a>&nbsp;&nbsp;<span class="src-key">return&nbsp;</span><span class="src-var">$count</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a853"></a><span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a854"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a855"></a><span class="src-doc">/**&nbsp;</span></div></li>
<li><div class="src-line"><a name="a856"></a><span class="src-doc">&nbsp;*&nbsp;Verifies&nbsp;that&nbsp;current&nbsp;login&nbsp;has&nbsp;admin&nbsp;privileges.</span></div></li>
<li><div class="src-line"><a name="a857"></a><span class="src-doc">&nbsp;*&nbsp;Note&nbsp;that&nbsp;various&nbsp;admin&nbsp;users&nbsp;can&nbsp;coexist&nbsp;on&nbsp;the&nbsp;CMS.</span></div></li>
<li><div class="src-line"><a name="a858"></a><span class="src-doc">&nbsp;*&nbsp;</span><span class="src-doc-coretag">@return&nbsp;</span><span class="src-doc">&nbsp;</span><span class="src-doc-type">boolean&nbsp;</span><span class="src-doc">&nbsp;&nbsp;TRUE&nbsp;on&nbsp;sucess,&nbsp;or&nbsp;FALSE&nbsp;on&nbsp;failure</span></div></li>
<li><div class="src-line"><a name="a859"></a><span class="src-doc">&nbsp;*/</span></div></li>
<li><div class="src-line"><a name="a860"></a><span class="src-key">function&nbsp;</span><a href="../smt2/_functions.php.html#functionis_admin">is_admin</a><span class="src-sym">(</span><span class="src-sym">)&nbsp;</span></div></li>
<li><div class="src-line"><a name="a861"></a><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a862"></a>&nbsp;&nbsp;<span class="src-key">if&nbsp;</span><span class="src-sym">(</span><span class="src-sym">!</span>isset<span class="src-sym">(</span><span class="src-var">$_SESSION</span><span class="src-sym">[</span><span class="src-str">'login'</span><span class="src-sym">]</span><span class="src-sym">))&nbsp;</span><span class="src-key">return&nbsp;</span><span class="src-id">false</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a863"></a>&nbsp;&nbsp;</div></li>
<li><div class="src-line"><a name="a864"></a>&nbsp;&nbsp;<span class="src-comm">//&nbsp;get&nbsp;admin&nbsp;role_id</span></div></li>
<li><div class="src-line"><a name="a865"></a>&nbsp;&nbsp;<span class="src-var">$user&nbsp;</span>=&nbsp;<a href="../smt2/_functions.db.php.html#functiondb_select">db_select</a><span class="src-sym">(</span><span class="src-id">TBL_PREFIX</span>.<span class="src-id"><a href="../smt2/_define.php.html#defineTBL_USERS">TBL_USERS</a></span><span class="src-sym">,&nbsp;</span><span class="src-str">&quot;role_id&quot;</span><span class="src-sym">,&nbsp;</span><span class="src-str">&quot;login='&quot;</span>.<span class="src-var">$_SESSION</span><span class="src-sym">[</span><span class="src-str">'login'</span><span class="src-sym">]</span>.<span class="src-str">&quot;'&quot;</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a866"></a>&nbsp;&nbsp;<span class="src-key">return&nbsp;</span><span class="src-sym">(&nbsp;</span>(int)&nbsp;<span class="src-var">$user</span><span class="src-sym">[</span><span class="src-str">'role_id'</span><span class="src-sym">]&nbsp;</span>===&nbsp;<span class="src-num">1&nbsp;</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a867"></a><span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a868"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a869"></a><span class="src-doc">/**&nbsp;</span></div></li>
<li><div class="src-line"><a name="a870"></a><span class="src-doc">&nbsp;*&nbsp;Verifies&nbsp;that&nbsp;current&nbsp;login&nbsp;is&nbsp;the&nbsp;superadmin&nbsp;user.</span></div></li>
<li><div class="src-line"><a name="a871"></a><span class="src-doc">&nbsp;*&nbsp;</span><span class="src-doc-coretag">@return&nbsp;</span><span class="src-doc">&nbsp;</span><span class="src-doc-type">boolean&nbsp;</span><span class="src-doc">&nbsp;&nbsp;TRUE&nbsp;on&nbsp;sucess,&nbsp;or&nbsp;FALSE&nbsp;on&nbsp;failure</span></div></li>
<li><div class="src-line"><a name="a872"></a><span class="src-doc">&nbsp;*/</span></div></li>
<li><div class="src-line"><a name="a873"></a><span class="src-key">function&nbsp;</span><a href="../smt2/_functions.php.html#functionis_root">is_root</a><span class="src-sym">(</span><span class="src-sym">)&nbsp;</span></div></li>
<li><div class="src-line"><a name="a874"></a><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a875"></a>&nbsp;&nbsp;<span class="src-key">if&nbsp;</span><span class="src-sym">(</span><span class="src-sym">!</span>isset<span class="src-sym">(</span><span class="src-var">$_SESSION</span><span class="src-sym">[</span><span class="src-str">'login'</span><span class="src-sym">]</span><span class="src-sym">))&nbsp;</span><span class="src-key">return&nbsp;</span><span class="src-id">false</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a876"></a>&nbsp;&nbsp;</div></li>
<li><div class="src-line"><a name="a877"></a>&nbsp;&nbsp;<span class="src-comm">//&nbsp;get&nbsp;root&nbsp;role_id</span></div></li>
<li><div class="src-line"><a name="a878"></a>&nbsp;&nbsp;<span class="src-var">$user&nbsp;</span>=&nbsp;<a href="../smt2/_functions.db.php.html#functiondb_select">db_select</a><span class="src-sym">(</span><span class="src-id">TBL_PREFIX</span>.<span class="src-id"><a href="../smt2/_define.php.html#defineTBL_USERS">TBL_USERS</a></span><span class="src-sym">,&nbsp;</span><span class="src-str">&quot;id&quot;</span><span class="src-sym">,&nbsp;</span><span class="src-str">&quot;login='&quot;</span>.<span class="src-var">$_SESSION</span><span class="src-sym">[</span><span class="src-str">'login'</span><span class="src-sym">]</span>.<span class="src-str">&quot;'&quot;</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a879"></a>&nbsp;&nbsp;<span class="src-key">return&nbsp;</span><span class="src-sym">(&nbsp;</span>(int)&nbsp;<span class="src-var">$user</span><span class="src-sym">[</span><span class="src-str">'id'</span><span class="src-sym">]&nbsp;</span>===&nbsp;<span class="src-num">1&nbsp;</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a880"></a><span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a881"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a882"></a><span class="src-doc">/**&nbsp;</span></div></li>
<li><div class="src-line"><a name="a883"></a><span class="src-doc">&nbsp;*&nbsp;Gets&nbsp;all&nbsp;allowed&nbsp;CMS&nbsp;extensions&nbsp;for&nbsp;the&nbsp;current&nbsp;user.</span></div></li>
<li><div class="src-line"><a name="a884"></a><span class="src-doc">&nbsp;*&nbsp;</span><span class="src-doc-coretag">@return&nbsp;</span><span class="src-doc">&nbsp;</span><span class="src-doc-type">array&nbsp;</span><span class="src-doc">&nbsp;&nbsp;Array&nbsp;of&nbsp;strings&nbsp;(sections)</span></div></li>
<li><div class="src-line"><a name="a885"></a><span class="src-doc">&nbsp;*/</span></div></li>
<li><div class="src-line"><a name="a886"></a><span class="src-key">function&nbsp;</span><a href="../smt2/_functions.php.html#functionis_allowed">is_allowed</a><span class="src-sym">(</span><span class="src-sym">)&nbsp;</span></div></li>
<li><div class="src-line"><a name="a887"></a><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a888"></a>&nbsp;&nbsp;<span class="src-comm">//&nbsp;check&nbsp;current&nbsp;user's&nbsp;role</span></div></li>
<li><div class="src-line"><a name="a889"></a>&nbsp;&nbsp;<span class="src-key">if&nbsp;</span><span class="src-sym">(</span><span class="src-var">$_SESSION</span><span class="src-sym">[</span><span class="src-str">'role_id'</span><span class="src-sym">]&nbsp;</span>&gt;&nbsp;<span class="src-num">0</span><span class="src-sym">)</span></div></li>
<li><div class="src-line"><a name="a890"></a>&nbsp;&nbsp;<span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a891"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$user&nbsp;</span>=&nbsp;<a href="../smt2/_functions.db.php.html#functiondb_select">db_select</a><span class="src-sym">(</span><span class="src-id">TBL_PREFIX</span>.<span class="src-id"><a href="../smt2/_define.php.html#defineTBL_USERS">TBL_USERS</a></span><span class="src-sym">,&nbsp;</span><span class="src-str">&quot;role_id&quot;</span><span class="src-sym">,&nbsp;</span><span class="src-str">&quot;login='&quot;</span>.<span class="src-var">$_SESSION</span><span class="src-sym">[</span><span class="src-str">'login'</span><span class="src-sym">]</span>.<span class="src-str">&quot;'&quot;</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a892"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-key">if&nbsp;</span><span class="src-sym">(&nbsp;</span>(int)&nbsp;<span class="src-var">$user</span><span class="src-sym">[</span><span class="src-str">'role_id'</span><span class="src-sym">]&nbsp;</span>!==&nbsp;<span class="src-num">1&nbsp;</span><span class="src-sym">)&nbsp;</span></div></li>
<li><div class="src-line"><a name="a893"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a894"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$current&nbsp;</span>=&nbsp;<a href="../smt2/_functions.php.html#functionext_name">ext_name</a><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a895"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-comm">//&nbsp;check&nbsp;if&nbsp;current&nbsp;section&nbsp;is&nbsp;allowed</span></div></li>
<li><div class="src-line"><a name="a896"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-key">return&nbsp;</span><span class="src-sym">(</span><a href="http://www.php.net/strpos">strpos</a><span class="src-sym">(</span><span class="src-var">$current</span><span class="src-sym">,&nbsp;</span><span class="src-var">$_SESSION</span><span class="src-sym">[</span><span class="src-str">'ext_allowed'</span><span class="src-sym">]</span><span class="src-sym">)&nbsp;</span>!==&nbsp;<span class="src-id">false</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a897"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-sym">}&nbsp;</span><span class="src-key">else&nbsp;</span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a898"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-key">return&nbsp;</span><span class="src-id">true</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a899"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a900"></a>&nbsp;&nbsp;<span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a901"></a>&nbsp;&nbsp;<span class="src-key">else&nbsp;</span></div></li>
<li><div class="src-line"><a name="a902"></a>&nbsp;&nbsp;<span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a903"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-key">return&nbsp;</span><span class="src-id">false</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a904"></a>&nbsp;&nbsp;<span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a905"></a><span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a906"></a>&nbsp;&nbsp;&nbsp;</div></li>
<li><div class="src-line"><a name="a907"></a><span class="src-doc">/**</span></div></li>
<li><div class="src-line"><a name="a908"></a><span class="src-doc">&nbsp;*&nbsp;Random&nbsp;Password&nbsp;Generator.</span></div></li>
<li><div class="src-line"><a name="a909"></a><span class="src-doc">&nbsp;*&nbsp;</span><span class="src-doc-tag">@autor</span><span class="src-doc">&nbsp;Charlie</span></div></li>
<li><div class="src-line"><a name="a910"></a><span class="src-doc">&nbsp;*&nbsp;</span><span class="src-doc-coretag">@link</span><span class="src-doc">&nbsp;http://snippets.dzone.com/user/Charlie</span></div></li>
<li><div class="src-line"><a name="a911"></a><span class="src-doc">&nbsp;*&nbsp;</span><span class="src-doc-coretag">@version</span><span class="src-doc">&nbsp;0.1.0&nbsp;-&nbsp;2006-02-14</span></div></li>
<li><div class="src-line"><a name="a912"></a><span class="src-doc">&nbsp;*/</span></div></li>
<li><div class="src-line"><a name="a913"></a><span class="src-key">function&nbsp;</span><a href="../smt2/_functions.php.html#functiongenerate_password">generate_password</a><span class="src-sym">(</span><span class="src-sym">)</span></div></li>
<li><div class="src-line"><a name="a914"></a><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a915"></a>&nbsp;&nbsp;<span class="src-var">$pwd&nbsp;</span>=&nbsp;<span class="src-key">array</span><span class="src-sym">(</span></div></li>
<li><div class="src-line"><a name="a916"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-str">&quot;C&quot;&nbsp;</span>=&gt;&nbsp;<span class="src-key">array</span><span class="src-sym">(</span><span class="src-str">'chars'&nbsp;</span>=&gt;&nbsp;<span class="src-str">'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'</span><span class="src-sym">,&nbsp;</span><span class="src-str">'min'&nbsp;</span>=&gt;&nbsp;<span class="src-num">4</span><span class="src-sym">,&nbsp;</span><span class="src-str">'max'&nbsp;</span>=&gt;&nbsp;<span class="src-num">6</span><span class="src-sym">)</span><span class="src-sym">,</span></div></li>
<li><div class="src-line"><a name="a917"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-str">&quot;S&quot;&nbsp;</span>=&gt;&nbsp;<span class="src-key">array</span><span class="src-sym">(</span><span class="src-str">'chars'&nbsp;</span>=&gt;&nbsp;<span class="src-str">&quot;!@()-_=+?*^&amp;&quot;</span><span class="src-sym">,&nbsp;</span><span class="src-str">'min'&nbsp;</span>=&gt;&nbsp;<span class="src-num">1</span><span class="src-sym">,&nbsp;</span><span class="src-str">'max'&nbsp;</span>=&gt;&nbsp;<span class="src-num">2</span><span class="src-sym">)</span><span class="src-sym">,</span></div></li>
<li><div class="src-line"><a name="a918"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-str">&quot;N&quot;&nbsp;</span>=&gt;&nbsp;<span class="src-key">array</span><span class="src-sym">(</span><span class="src-str">'chars'&nbsp;</span>=&gt;&nbsp;<span class="src-str">'1234567890'</span><span class="src-sym">,&nbsp;</span><span class="src-str">'min'&nbsp;</span>=&gt;&nbsp;<span class="src-num">2</span><span class="src-sym">,&nbsp;</span><span class="src-str">'max'&nbsp;</span>=&gt;&nbsp;<span class="src-num">2</span><span class="src-sym">)</span></div></li>
<li><div class="src-line"><a name="a919"></a>&nbsp;&nbsp;<span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a920"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-comm">//&nbsp;Create&nbsp;the&nbsp;meta-password</span></div></li>
<li><div class="src-line"><a name="a921"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$meta&nbsp;</span>=&nbsp;<span class="src-str">&quot;&quot;</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a922"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-key">foreach&nbsp;</span><span class="src-sym">(</span><span class="src-var">$pwd&nbsp;</span><span class="src-key">as&nbsp;</span><span class="src-var">$cToken&nbsp;</span>=&gt;&nbsp;<span class="src-var">$seed</span><span class="src-sym">)&nbsp;</span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a923"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$meta&nbsp;</span>.=&nbsp;<a href="http://www.php.net/str_repeat">str_repeat</a><span class="src-sym">(</span><span class="src-var">$cToken</span><span class="src-sym">,&nbsp;</span><a href="http://www.php.net/rand">rand</a><span class="src-sym">(</span><span class="src-var">$seed</span><span class="src-sym">[</span><span class="src-str">'min'</span><span class="src-sym">]</span><span class="src-sym">,&nbsp;</span><span class="src-var">$seed</span><span class="src-sym">[</span><span class="src-str">'max'</span><span class="src-sym">]</span><span class="src-sym">))</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a924"></a>&nbsp;&nbsp;<span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a925"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$meta&nbsp;</span>=&nbsp;<a href="http://www.php.net/str_shuffle">str_shuffle</a><span class="src-sym">(</span><span class="src-var">$meta</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a926"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-comm">//&nbsp;Create&nbsp;the&nbsp;real&nbsp;password</span></div></li>
<li><div class="src-line"><a name="a927"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$buffer&nbsp;</span>=&nbsp;<span class="src-key">array</span><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a928"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-key">for&nbsp;</span><span class="src-sym">(</span><span class="src-var">$i&nbsp;</span>=&nbsp;<span class="src-num">0</span><span class="src-sym">;&nbsp;</span><span class="src-var">$i&nbsp;</span>&lt;&nbsp;<a href="http://www.php.net/strlen">strlen</a><span class="src-sym">(</span><span class="src-var">$meta</span><span class="src-sym">)</span><span class="src-sym">;&nbsp;</span>++<span class="src-var">$i</span><span class="src-sym">)&nbsp;</span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a929"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$buffer</span><span class="src-sym">[</span><span class="src-sym">]&nbsp;</span>=&nbsp;<span class="src-var">$pwd</span><span class="src-sym">[</span>(string)<span class="src-var">$meta</span><span class="src-sym">[</span><span class="src-var">$i</span><span class="src-sym">]]</span><span class="src-sym">[</span><span class="src-str">'chars'</span><span class="src-sym">]</span><span class="src-sym">[</span><a href="http://www.php.net/rand">rand</a><span class="src-sym">(</span><span class="src-num">0</span><span class="src-sym">,&nbsp;</span><a href="http://www.php.net/strlen">strlen</a><span class="src-sym">(</span><span class="src-var">$pwd</span><span class="src-sym">[</span><span class="src-var">$meta</span><span class="src-sym">[</span><span class="src-var">$i</span><span class="src-sym">]]</span><span class="src-sym">[</span><span class="src-str">'chars'</span><span class="src-sym">]</span><span class="src-sym">)&nbsp;</span>-&nbsp;<span class="src-num">1</span><span class="src-sym">)</span><span class="src-sym">]</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a930"></a>&nbsp;&nbsp;<span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a931"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a932"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-key">return&nbsp;</span><a href="http://www.php.net/implode">implode</a><span class="src-sym">(</span><span class="src-str">&quot;&quot;</span><span class="src-sym">,&nbsp;</span><span class="src-var">$buffer</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a933"></a><span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a934"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a935"></a><span class="src-doc">/**</span></div></li>
<li><div class="src-line"><a name="a936"></a><span class="src-doc">&nbsp;*&nbsp;Checks&nbsp;if&nbsp;an&nbsp;email&nbsp;address&nbsp;is&nbsp;valid.</span></div></li>
<li><div class="src-line"><a name="a937"></a><span class="src-doc">&nbsp;*&nbsp;The&nbsp;chars&nbsp;#&nbsp;$&nbsp;%&nbsp;&amp;&nbsp;'&nbsp;*&nbsp;+&nbsp;/&nbsp;=&nbsp;?&nbsp;^&nbsp;`&nbsp;{&nbsp;|&nbsp;}&nbsp;~&nbsp;are&nbsp;theoretically&nbsp;allowed&nbsp;on&nbsp;the&nbsp;local&nbsp;part,</span></div></li>
<li><div class="src-line"><a name="a938"></a><span class="src-doc">&nbsp;*&nbsp;but&nbsp;in&nbsp;practice&nbsp;they&nbsp;are&nbsp;discarded.</span></div></li>
<li><div class="src-line"><a name="a939"></a><span class="src-doc">&nbsp;*&nbsp;</span><span class="src-doc-coretag">@param&nbsp;</span><span class="src-doc">&nbsp;&nbsp;</span><span class="src-doc-type">string&nbsp;</span><span class="src-doc">&nbsp;&nbsp;&nbsp;</span><span class="src-doc-var">$email&nbsp;</span><span class="src-doc">&nbsp;email&nbsp;to&nbsp;check</span></div></li>
<li><div class="src-line"><a name="a940"></a><span class="src-doc">&nbsp;*&nbsp;</span><span class="src-doc-coretag">@return&nbsp;</span><span class="src-doc">&nbsp;</span><span class="src-doc-type">boolean&nbsp;</span><span class="src-doc">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;TRUE&nbsp;on&nbsp;sucess,&nbsp;or&nbsp;FALSE&nbsp;on&nbsp;failure</span></div></li>
<li><div class="src-line"><a name="a941"></a><span class="src-doc">&nbsp;*&nbsp;</span><span class="src-doc-coretag">@link</span><span class="src-doc">&nbsp;&nbsp;&nbsp;&nbsp;http://tools.ietf.org/html/rfc5321</span></div></li>
<li><div class="src-line"><a name="a942"></a><span class="src-doc">&nbsp;*&nbsp;</span><span class="src-doc-coretag">@link</span><span class="src-doc">&nbsp;&nbsp;&nbsp;&nbsp;http://tools.ietf.org/html/rfc5322</span></div></li>
<li><div class="src-line"><a name="a943"></a><span class="src-doc">&nbsp;*/</span></div></li>
<li><div class="src-line"><a name="a944"></a><span class="src-key">function&nbsp;</span><a href="../smt2/_functions.php.html#functionis_email">is_email</a><span class="src-sym">(</span><span class="src-var">$email</span><span class="src-sym">)</span></div></li>
<li><div class="src-line"><a name="a945"></a><span class="src-sym">{&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></div></li>
<li><div class="src-line"><a name="a946"></a>&nbsp;&nbsp;<span class="src-key">return&nbsp;</span><a href="http://www.php.net/eregi">eregi</a><span class="src-sym">(</span><span class="src-str">&quot;^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$&quot;</span><span class="src-sym">,&nbsp;</span><span class="src-var">$email</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a947"></a><span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a948"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a949"></a><span class="src-doc">/**</span></div></li>
<li><div class="src-line"><a name="a950"></a><span class="src-doc">&nbsp;*&nbsp;Searches&nbsp;DNS&nbsp;for&nbsp;MX&nbsp;records&nbsp;corresponding&nbsp;to&nbsp;user's&nbsp;email&nbsp;account&nbsp;hostname.</span></div></li>
<li><div class="src-line"><a name="a951"></a><span class="src-doc">&nbsp;*&nbsp;</span><span class="src-doc-coretag">@param&nbsp;</span><span class="src-doc">&nbsp;&nbsp;</span><span class="src-doc-type">string&nbsp;</span><span class="src-doc">&nbsp;&nbsp;&nbsp;</span><span class="src-doc-var">$email&nbsp;</span><span class="src-doc">&nbsp;user&nbsp;email</span></div></li>
<li><div class="src-line"><a name="a952"></a><span class="src-doc">&nbsp;*&nbsp;</span><span class="src-doc-coretag">@return&nbsp;</span><span class="src-doc">&nbsp;</span><span class="src-doc-type">boolean&nbsp;</span><span class="src-doc">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;TRUE&nbsp;on&nbsp;sucess,&nbsp;or&nbsp;FALSE&nbsp;on&nbsp;failure</span></div></li>
<li><div class="src-line"><a name="a953"></a><span class="src-doc">&nbsp;*/</span></div></li>
<li><div class="src-line"><a name="a954"></a><span class="src-key">function&nbsp;</span><a href="../smt2/_functions.php.html#functionemail_exists">email_exists</a><span class="src-sym">(</span><span class="src-var">$email</span><span class="src-sym">)</span></div></li>
<li><div class="src-line"><a name="a955"></a><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a956"></a>&nbsp;&nbsp;<span class="src-key">if&nbsp;</span><span class="src-sym">(</span><span class="src-sym">!</span><a href="../smt2/_functions.php.html#functionis_email">is_email</a><span class="src-sym">(</span><span class="src-var">$email</span><span class="src-sym">))&nbsp;</span><span class="src-sym">{&nbsp;</span><span class="src-key">return&nbsp;</span><span class="src-id">false</span><span class="src-sym">;&nbsp;</span><span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a957"></a>&nbsp;&nbsp;</div></li>
<li><div class="src-line"><a name="a958"></a>&nbsp;&nbsp;list<span class="src-sym">(</span><span class="src-var">$user</span><span class="src-sym">,&nbsp;</span><span class="src-var">$domain</span><span class="src-sym">)&nbsp;</span>=&nbsp;<a href="http://www.php.net/split">split</a><span class="src-sym">(</span><span class="src-str">&quot;@&quot;</span><span class="src-sym">,&nbsp;</span><span class="src-var">$email</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a959"></a>&nbsp;&nbsp;<span class="src-key">if&nbsp;</span><span class="src-sym">(</span><a href="http://www.php.net/function_exists">function_exists</a><span class="src-sym">(</span><span class="src-str">'getmxrr'</span><span class="src-sym">)&nbsp;</span>&amp;&amp;&nbsp;<span class="src-id">getmxrr</span><span class="src-sym">(</span><span class="src-var">$domain</span><span class="src-sym">,&nbsp;</span><span class="src-var">$MXHost</span><span class="src-sym">))&nbsp;</span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a960"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-key">return&nbsp;</span><span class="src-id">true</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a961"></a>&nbsp;&nbsp;<span class="src-sym">}&nbsp;</span><span class="src-key">else&nbsp;</span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a962"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-key">return&nbsp;</span><span class="src-sym">(</span><a href="http://www.php.net/fsockopen">fsockopen</a><span class="src-sym">(</span><span class="src-var">$domain</span><span class="src-sym">,&nbsp;</span><span class="src-num">80</span><span class="src-sym">,&nbsp;</span><span class="src-var">$errno</span><span class="src-sym">,&nbsp;</span><span class="src-var">$errstr</span><span class="src-sym">,&nbsp;</span><span class="src-num">30</span><span class="src-sym">))</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a963"></a>&nbsp;&nbsp;<span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a964"></a><span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a965"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a966"></a><span class="src-doc">/**</span></div></li>
<li><div class="src-line"><a name="a967"></a><span class="src-doc">&nbsp;*&nbsp;Stops&nbsp;executing&nbsp;a&nbsp;PHP&nbsp;script,&nbsp;displaying&nbsp;a&nbsp;reason&nbsp;for&nbsp;the&nbsp;error.</span></div></li>
<li><div class="src-line"><a name="a968"></a><span class="src-doc">&nbsp;*&nbsp;</span><span class="src-doc-coretag">@param&nbsp;</span><span class="src-doc">&nbsp;&nbsp;</span><span class="src-doc-type">string&nbsp;</span><span class="src-doc">&nbsp;&nbsp;&nbsp;</span><span class="src-doc-var">$text&nbsp;</span><span class="src-doc">&nbsp;message</span></div></li>
<li><div class="src-line"><a name="a969"></a><span class="src-doc">&nbsp;*/</span></div></li>
<li><div class="src-line"><a name="a970"></a><span class="src-key">function&nbsp;</span><a href="../smt2/_functions.php.html#functiondie_msg">die_msg</a><span class="src-sym">(</span><span class="src-var">$text&nbsp;</span>=&nbsp;<span class="src-str">&quot;&quot;</span><span class="src-sym">)</span></div></li>
<li><div class="src-line"><a name="a971"></a><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a972"></a>&nbsp;&nbsp;<span class="src-key">if&nbsp;</span><span class="src-sym">(</span><span class="src-sym">!</span><span class="src-key">empty</span><span class="src-sym">(</span><span class="src-var">$text</span><span class="src-sym">))&nbsp;</span><span class="src-sym">{&nbsp;</span><span class="src-var">$text&nbsp;</span>=&nbsp;<span class="src-str">&quot;:&nbsp;&quot;&nbsp;</span>.&nbsp;<span class="src-var">$text</span><span class="src-sym">;&nbsp;</span><span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a973"></a>&nbsp;&nbsp;</div></li>
<li><div class="src-line"><a name="a974"></a>&nbsp;&nbsp;<span class="src-key">die</span><span class="src-sym">(</span><span class="src-str">&quot;&lt;strong&gt;Error&lt;/strong&gt;&quot;</span>.<span class="src-var">$text</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a975"></a><span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a976"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a977"></a><span class="src-doc">/**</span></div></li>
<li><div class="src-line"><a name="a978"></a><span class="src-doc">&nbsp;*&nbsp;Pad&nbsp;with&nbsp;zeros&nbsp;a&nbsp;number.</span></div></li>
<li><div class="src-line"><a name="a979"></a><span class="src-doc">&nbsp;*&nbsp;</span><span class="src-doc-coretag">@param&nbsp;</span><span class="src-doc-type">int&nbsp;</span><span class="src-doc-var">$num&nbsp;</span><span class="src-doc">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;input&nbsp;number</span></div></li>
<li><div class="src-line"><a name="a980"></a><span class="src-doc">&nbsp;*&nbsp;</span><span class="src-doc-coretag">@param&nbsp;</span><span class="src-doc-type">int&nbsp;</span><span class="src-doc-var">$numZeros&nbsp;</span><span class="src-doc">number&nbsp;of&nbsp;zeros</span></div></li>
<li><div class="src-line"><a name="a981"></a><span class="src-doc">&nbsp;*/</span></div></li>
<li><div class="src-line"><a name="a982"></a><span class="src-key">function&nbsp;</span><a href="../smt2/_functions.php.html#functionpad_number">pad_number</a><span class="src-sym">(</span><span class="src-var">$num</span><span class="src-sym">,&nbsp;</span><span class="src-var">$numZeros</span><span class="src-sym">)</span></div></li>
<li><div class="src-line"><a name="a983"></a><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a984"></a>&nbsp;&nbsp;<span class="src-key">return&nbsp;</span><a href="http://www.php.net/sprintf">sprintf</a><span class="src-sym">(</span><span class="src-str">&quot;%0&quot;</span>.<span class="src-var">$numZeros</span>.<span class="src-str">&quot;d&quot;</span><span class="src-sym">,&nbsp;</span><span class="src-var">$num</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a985"></a><span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a986"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a987"></a><span class="src-doc">/**&nbsp;Emulates&nbsp;register_globals&nbsp;off.&nbsp;*/</span></div></li>
<li><div class="src-line"><a name="a988"></a><span class="src-key">function&nbsp;</span><a href="../smt2/_functions.php.html#functionunregister_GLOBALS">unregister_GLOBALS</a><span class="src-sym">(</span><span class="src-sym">)</span></div></li>
<li><div class="src-line"><a name="a989"></a><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a990"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-key">if&nbsp;</span><span class="src-sym">(</span><span class="src-sym">!</span><a href="http://www.php.net/ini_get">ini_get</a><span class="src-sym">(</span><span class="src-str">'register_globals'</span><span class="src-sym">))&nbsp;</span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a991"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-key">return</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a992"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a993"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a994"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-comm">//&nbsp;might&nbsp;want&nbsp;to&nbsp;change&nbsp;this&nbsp;perhaps&nbsp;to&nbsp;a&nbsp;nicer&nbsp;error</span></div></li>
<li><div class="src-line"><a name="a995"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-key">if&nbsp;</span><span class="src-sym">(</span>isset<span class="src-sym">(</span><span class="src-var">$_REQUEST</span><span class="src-sym">[</span><span class="src-str">'GLOBALS'</span><span class="src-sym">]</span><span class="src-sym">)&nbsp;</span>||&nbsp;isset<span class="src-sym">(</span><span class="src-var">$_FILES</span><span class="src-sym">[</span><span class="src-str">'GLOBALS'</span><span class="src-sym">]</span><span class="src-sym">))&nbsp;</span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a996"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-key">die</span><span class="src-sym">(</span><span class="src-str">'GLOBALS&nbsp;overwrite&nbsp;attempt&nbsp;detected'</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a997"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a998"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a999"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-comm">//&nbsp;variables&nbsp;that&nbsp;shouldn't&nbsp;be&nbsp;unset</span></div></li>
<li><div class="src-line"><a name="a1000"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$noUnset&nbsp;</span>=&nbsp;<span class="src-key">array</span><span class="src-sym">(</span><span class="src-str">'GLOBALS'</span><span class="src-sym">,&nbsp;&nbsp;</span><span class="src-str">'_GET'</span><span class="src-sym">,</span></div></li>
<li><div class="src-line"><a name="a1001"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-str">'_POST'</span><span class="src-sym">,&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="src-str">'_COOKIE'</span><span class="src-sym">,</span></div></li>
<li><div class="src-line"><a name="a1002"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-str">'_REQUEST'</span><span class="src-sym">,&nbsp;</span><span class="src-str">'_SERVER'</span><span class="src-sym">,</span></div></li>
<li><div class="src-line"><a name="a1003"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-str">'_ENV'</span><span class="src-sym">,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="src-str">'_FILES'</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a1004"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a1005"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$input&nbsp;</span>=&nbsp;<a href="http://www.php.net/array_merge">array_merge</a><span class="src-sym">(</span><span class="src-var">$_GET</span><span class="src-sym">,&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="src-var">$_POST</span><span class="src-sym">,</span></div></li>
<li><div class="src-line"><a name="a1006"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$_COOKIE</span><span class="src-sym">,&nbsp;</span><span class="src-var">$_SERVER</span><span class="src-sym">,</span></div></li>
<li><div class="src-line"><a name="a1007"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$_ENV</span><span class="src-sym">,&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="src-var">$_FILES</span><span class="src-sym">,</span></div></li>
<li><div class="src-line"><a name="a1008"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;isset<span class="src-sym">(</span><span class="src-var">$_SESSION</span><span class="src-sym">)&nbsp;</span>&amp;&amp;&nbsp;<a href="http://www.php.net/is_array">is_array</a><span class="src-sym">(</span><span class="src-var">$_SESSION</span><span class="src-sym">)&nbsp;</span>?&nbsp;<span class="src-var">$_SESSION&nbsp;</span>:&nbsp;<span class="src-key">array</span><span class="src-sym">(</span><span class="src-sym">))</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a1009"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a1010"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-key">foreach&nbsp;</span><span class="src-sym">(</span><span class="src-var">$input&nbsp;</span><span class="src-key">as&nbsp;</span><span class="src-var">$k&nbsp;</span>=&gt;&nbsp;<span class="src-var">$v</span><span class="src-sym">)&nbsp;</span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a1011"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-key">if&nbsp;</span><span class="src-sym">(</span><span class="src-sym">!</span><a href="http://www.php.net/in_array">in_array</a><span class="src-sym">(</span><span class="src-var">$k</span><span class="src-sym">,&nbsp;</span><span class="src-var">$noUnset</span><span class="src-sym">)&nbsp;</span>&amp;&amp;&nbsp;isset<span class="src-sym">(</span><span class="src-var">$GLOBALS</span><span class="src-sym">[</span><span class="src-var">$k</span><span class="src-sym">]</span><span class="src-sym">))&nbsp;</span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a1012"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;unset<span class="src-sym">(</span><span class="src-var">$GLOBALS</span><span class="src-sym">[</span><span class="src-var">$k</span><span class="src-sym">]</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a1013"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a1014"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a1015"></a><span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a1016"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a1017"></a><span class="src-doc">/**</span></div></li>
<li><div class="src-line"><a name="a1018"></a><span class="src-doc">&nbsp;*&nbsp;Gets&nbsp;a&nbsp;SQL-alike&nbsp;string&nbsp;with&nbsp;all&nbsp;cache&nbsp;IDs&nbsp;that&nbsp;are&nbsp;related&nbsp;to&nbsp;the&nbsp;same&nbsp;URL.</span></div></li>
<li><div class="src-line"><a name="a1019"></a><span class="src-doc">&nbsp;*&nbsp;</span><span class="src-doc-coretag">@param&nbsp;</span><span class="src-doc">&nbsp;&nbsp;</span><span class="src-doc-type">int&nbsp;</span><span class="src-doc">&nbsp;&nbsp;&nbsp;&nbsp;Log&nbsp;cache&nbsp;ID</span></div></li>
<li><div class="src-line"><a name="a1020"></a><span class="src-doc">&nbsp;*&nbsp;</span><span class="src-doc-coretag">@return&nbsp;</span><span class="src-doc">&nbsp;</span><span class="src-doc-type">string&nbsp;</span><span class="src-doc">&nbsp;SQL&nbsp;query</span></div></li>
<li><div class="src-line"><a name="a1021"></a><span class="src-doc">&nbsp;*/</span></div></li>
<li><div class="src-line"><a name="a1022"></a><span class="src-key">function&nbsp;</span><a href="../smt2/_functions.php.html#functionget_common_url">get_common_url</a><span class="src-sym">(</span><span class="src-var">$pageId</span><span class="src-sym">)</span></div></li>
<li><div class="src-line"><a name="a1023"></a><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a1024"></a>&nbsp;&nbsp;<span class="src-var">$common&nbsp;</span>=&nbsp;<a href="../smt2/_functions.db.php.html#functiondb_select">db_select</a><span class="src-sym">(</span><span class="src-id">TBL_PREFIX</span>.<span class="src-id"><a href="../smt2/_define.php.html#defineTBL_CACHE">TBL_CACHE</a></span><span class="src-sym">,&nbsp;</span><span class="src-str">&quot;url&quot;</span><span class="src-sym">,&nbsp;</span><span class="src-str">&quot;id&nbsp;=&nbsp;'&quot;</span>.<span class="src-var">$pageId</span>.<span class="src-str">&quot;'&quot;</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a1025"></a>&nbsp;&nbsp;<span class="src-var">$moreId&nbsp;</span>=&nbsp;<a href="../smt2/_functions.db.php.html#functiondb_select_all">db_select_all</a><span class="src-sym">(</span><span class="src-id">TBL_PREFIX</span>.<span class="src-id"><a href="../smt2/_define.php.html#defineTBL_CACHE">TBL_CACHE</a></span><span class="src-sym">,&nbsp;</span><span class="src-str">&quot;id&quot;</span><span class="src-sym">,&nbsp;</span><span class="src-str">&quot;url&nbsp;=&nbsp;'&quot;</span>.<span class="src-var">$common</span><span class="src-sym">[</span><span class="src-str">'url'</span><span class="src-sym">]</span>.<span class="src-str">&quot;'&quot;</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a1026"></a>&nbsp;&nbsp;<span class="src-comm">//&nbsp;merge&nbsp;values</span></div></li>
<li><div class="src-line"><a name="a1027"></a>&nbsp;&nbsp;<span class="src-var">$moreId&nbsp;</span>=&nbsp;<a href="../smt2/_functions.php.html#functionarray_flatten">array_flatten</a><span class="src-sym">(</span><span class="src-var">$moreId</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a1028"></a>&nbsp;&nbsp;<span class="src-comm">//&nbsp;set&nbsp;query</span></div></li>
<li><div class="src-line"><a name="a1029"></a>&nbsp;&nbsp;<span class="src-var">$merge&nbsp;</span>=&nbsp;<span class="src-str">&quot;&quot;</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a1030"></a>&nbsp;&nbsp;<span class="src-key">foreach&nbsp;</span><span class="src-sym">(</span><span class="src-var">$moreId&nbsp;</span><span class="src-key">as&nbsp;</span><span class="src-var">$k&nbsp;</span>=&gt;&nbsp;<span class="src-var">$value</span><span class="src-sym">)&nbsp;</span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a1031"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-key">if&nbsp;</span><span class="src-sym">(</span><span class="src-var">$value&nbsp;</span>!=&nbsp;<span class="src-var">$pageId</span><span class="src-sym">)</span></div></li>
<li><div class="src-line"><a name="a1032"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$merge&nbsp;</span>.=&nbsp;<span class="src-str">&quot;&nbsp;OR&nbsp;cache_id='&quot;</span>.<span class="src-var">$value</span>.<span class="src-str">&quot;'&nbsp;&quot;</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a1033"></a>&nbsp;&nbsp;<span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a1034"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a1035"></a>&nbsp;&nbsp;<span class="src-key">return&nbsp;</span><span class="src-var">$merge</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a1036"></a><span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a1037"></a><span class="src-php">?&gt;</span></div></li>
</ol>
</div>
        <div class="credit">
		    <hr />
		    Documentation generated on Sun, 21 Feb 2010 16:08:04 +0100 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.1</a>
	      </div>
      </td></tr></table>
    </td>
  </tr>
</table>

</body>
</html>